Git Product home page Git Product logo

lara-asp's Introduction

Awesome Set of Packages for Laravel

The set provides best practices to make development more fun and classes/services that I found very useful while working on big extensible applications.

Requirements

Requirement Constraint Supported by
PHP ^8.3 HEAD ⋯ 5.0.0
^8.2 HEAD ⋯ 2.0.0
^8.1 HEAD ⋯ 2.0.0
^8.0 4.6.0 ⋯ 2.0.0
^8.0.0 1.1.2 ⋯ 0.12.0
>=8.0.0 0.11.0 ⋯ 0.4.0
>=7.4.0 0.3.0 ⋯ 0.1.0
Laravel ^11.0.0 HEAD ⋯ 6.2.0
^10.34.0 HEAD ⋯ 6.2.0
^10.0.0 6.1.0 ⋯ 2.1.0
^9.21.0 5.6.0 ⋯ 5.0.0-beta.1
^9.0.0 5.0.0-beta.0 ⋯ 0.12.0
^8.22.1 3.0.0 ⋯ 0.2.0
^8.0 0.1.0

Installation

Installation of the root lastdragon-ru/lara-asp package is not recommended because it will install all packages, but some of them are intended to use while dev only (and may want dependencies like phpunit/phpstan/etc). So select the desired package and install it. You can find requirements and installation instructions (if any) inside package documentation.

# General case (where "<package>" the package name).
composer require lastdragon-ru/lara-asp-<package>

Packages

🐝 Package intended to use in dev.

(Laravel) Core

This package contains useful utilities and classes.

Read more.

(Laravel) Documentator

This package provides various utilities for documentation generation such as Markdown Preprocessor, Requirements Dumper and more.

Read more.

(Laravel) Eloquent Helpers

This package contains useful extensions and mixins for Eloquent.

Read more.

(Laravel) GraphQL Extensions for Lighthouse

This package provides highly powerful @searchBy, @sortBy, @stream directives for lighthouse-php. The @searchBy directive provides basic conditions like =, >, <, etc, relations, not (<condition>), enums, and custom operators support. All are strictly typed so you no need to use Mixed type anymore. The @sortBy is not only about standard sorting by columns but also allows use relations. 😎

Read more.

(Laravel) Intl Formatter

This package provides a customizable wrapper around Intl formatters to use it inside Laravel application.

Read more.

(Laravel) Raw SQL Migrator/Seeder

This package improves standard Laravel migrations to add support for raw SQL files during migration and seeding. So you can easily use your favorite visual tool for database development like MySQL Workbench with Laravel 🥳

Read more.

(Laravel) SPA Helpers

Read more.

(Laravel) Symfony Serializer

This package provides a customizable wrapper around the Symfony Serializer Component to use it inside Laravel application.

Read more.

(Laravel) Testing Helpers 🐝

This package provides various useful asserts for PHPUnit and better solution for HTTP tests - testing HTTP response has never been so easy! And this not only about TestResponse but any PSR response 😎

Read more.

Dev 🐝

Various internal tools and helpers to develop the package itself.

Read more.

GraphQL Printer

Independent (from Laravel and Lighthouse) package that allow you to print GraphQL Schema and Queries in highly customized way eg you can choose indent size, print only used/wanted/all types, print only one type, print used/wanted/all directives (it is not possible with standard printer) and even check which types/directives are used in the Schema/Query.

Read more.

Upgrading

Please follow Upgrade Guide.

Development

  1. Fork & clone
  2. docker compose up
  3. ...
  4. Enjoy

Legend

Icon Place Description
🧪 Docs Experimental feature. Any feedback would be greatly appreciated.
🐝 Docs Package intended to use in dev.
🤝 Docs Backward-compatible change.
💀 Docs Deprecated feature.
🡹 CI The highest versions of dependencies are used.
🔒 CI The locked versions of dependencies are used.
🡻 CI The lowest versions of dependencies are used.
🪓 CI The optional dependencies are removed.
🆄 CI Running on Ubuntu
🆆 CI Running on Windows
🅼 CI Running on Mac OS X

lara-asp's People

Contributors

lastdragon-ru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jaulz

lara-asp's Issues

Interface support while types transformation

For the following example, the interface I will not be updated and the schema will be invalid.

interface I {
    contacts (
        where: ContactsQuery @searchBy
        order: ContactsSort @sortBy
    ): [Contact!]!
}

type A implements I {
    contacts (
        where: ContactsQuery @searchBy
        order: ContactsSort @sortBy
    ): [Contact!]!
}

Separate project for phpunit assertions?

After #140, #117, #141 probably more actual to extract all assertions into separate packages. That will remove all implicit dependencies from phpunit, but we will have few more (small) packages. It may be difficult to support and it will create more tasks in actions (maybe even we can reach the limit (256?)).

Also, the src/Testing/**.php should not be related to dev packages (possible only after spliting).

Impossible to use @searchBy directive with custom FieldResolver directive

Hello,

after upgrading package to v4, in addition with latest version of webonyx/graphql and nuwave/lighthouse, it is impossible to use @searchby directive with custom resolver directive.

I have @report directive which is very similar to @all directive, but adds some eloquent builder methods.

My schema is:

input CouponFilter {
    id: ID
    name: String
    code: String
    type: String
}

coupons(filter: CouponFilter @searchBy): [Coupon] @all

couponReport(filter: CouponFilter @searchBy): [CouponReport] @report
  1. When I remove filter: CouponFilter @searchBy from couponReport - everything is fine.
  2. When I change @report to @all in couponReport query - everything is fine.
  3. When I change body of @report directive class to be exactly as @all - does not work
  4. When I change CouponReport to Coupon as return type of couponReport query - does not work.

Error is:

 LastDragon_ru\LaraASP\GraphQL\Builder\Exceptions\TypeDefinitionImpossibleToCreateType 

  Definition `LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Scalar`: Impossible to create type for type `input CouponFilter { id }`.

  at vendor/lastdragon-ru/lara-asp-graphql/src/Builder/Manipulator.php:97
     93▕         // Create new
     94▕         $node = $instance->getTypeDefinitionNode($this, $name, $source);
     95▕ 
     96▕         if (!$node) {
  ➜  97▕             throw new TypeDefinitionImpossibleToCreateType($definition, $source);
     98▕         }
     99▕ 
    100▕         if ($name !== $this->getNodeName($node)) {
    101▕             throw new TypeDefinitionInvalidTypeName($definition, $name, $this->getNodeName($node));

The error must happened with recent changes, because before version 4 I was using dev-master and everything was fine.

Edit:

Probably it is related with commit c3ffa70

But that way disables usage of custom resolvers :(

lighthouse:validate-schema failing after update to 4.2.0

Hi,

on version 4.1.0 everything is fine.
Error:

[2023-06-18 15:58:37] local.ERROR: No directive @equal defined.

GraphQL request (7:5)
6:     equal: DateTimeTz
7:     @equal
       ^
8:     """Within a range."""


No directive @between defined.

GraphQL request (10:5)
 9:     between: SearchByTypeRangeDateTimeTz
10:     @between
        ^
11:     """Less than (`<`)."""


No directive @lessThan defined.

GraphQL request (13:5)
12:     lessThan: DateTimeTz
13:     @lessThan
        ^
14:     """Greater than (`>`)."""


No directive @greaterThan defined.

GraphQL request (16:5)
15:     greaterThan: DateTimeTz
16:     @greaterThan
        ^
17:     """Less than or equal to (`<=`)."""


No directive @lessThanOrEqual defined.

GraphQL request (19:5)
18:     lessThanOrEqual: DateTimeTz
19:     @lessThanOrEqual
        ^
20:     """Greater than or equal to (`>=`)."""


No directive @greaterThanOrEqual defined.

GraphQL request (22:5)
21:     greaterThanOrEqual: DateTimeTz
22:     @greaterThanOrEqual
        ^
23:     """Contains."""

Basically looks like any of directives from package are not detected.

Query support

Would be nice to be able to print the graphql queries too.

Filters in sort

Hi,
look at this query:

query {
  categories(
    first: 100
    sort: [
      {
        translation: {
          name: DESC
        }
      }
    ]
    filter: {
      translation: {
        where: {
          language_id: {
            equal: "en-GB"
          }
        }
      }
    }
  ) {
    data {
      id
      translation(
        language_id: "en-GB"
      ) {
        name
      }
    }
  }
}

As you see, I filter product that have language "en-GB" in translations, and sort them by language.name. But my first language in table is "pl", so results are sorted by first language in table.

One of proposal is extend @sortby directive to accept simple "where" condition:

query {
  categories(
    first: 100
    sort: [
      {
        translation: {
          where: {
          language_id: {
            equal: "en-GB"
          }
        }
          name: DESC
        }
      }
    ]
    filter: {
      translation: {
        where: {
          language_id: {
            equal: "en-GB"
          }
        }
      }
    }
  ) {
    data {
      id
      translation(
        language_id: "en-GB"
      ) {
        name
      }
    }
  }
}

or make search in @searchby directive:

query {
  categories(
    first: 100
    sort: [
      {
        translation: {
          name: DESC
        }
      }
    ]
    filter: {
      translation: {
        where: {
          language_id: {
            equal: "en-GB"
            sort: true
          }
        }
      }
    }
  ) {
    data {
      id
      translation(
        language_id: "en-GB"
      ) {
        name
      }
    }
  }
}

What do you think?

`@searchBy` stop working on Octane and `LIGHTHOUSE_CACHE=false`

Hi,

on Laravel Octane with Swoole, and when LIGHTHOUSE_CACHE is set to false, after second request there is a bug:


  "errors": [
    {
      "debugMessage": "LastDragon_ru\\LaraASP\\GraphQL\\Builder\\Directives\\HandlerDirective::handle(): Argument #3 ($conditions) must be of type Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet, array given, called in /var/www/html/vendor/lastdragon-ru/lara-asp-graphql/src/Builder/Directives/HandlerDirective.php on line 61",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "users"
      ],
      "trace": [
        {
          "file": "/var/www/html/vendor/lastdragon-ru/lara-asp-graphql/src/Builder/Directives/HandlerDirective.php",
          "line": 61,
          "call": "LastDragon_ru\\LaraASP\\GraphQL\\Builder\\Directives\\HandlerDirective::handle()"
        },
        {
          "file": "/var/www/html/vendor/lastdragon-ru/lara-asp-graphql/src/SearchBy/Directives/Directive.php",
          "line": 54,
          "call": "LastDragon_ru\\LaraASP\\GraphQL\\Builder\\Directives\\HandlerDirective::handleAnyBuilder()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Execution/Arguments/ArgumentSet.php",
          "line": 129,
          "call": "LastDragon_ru\\LaraASP\\GraphQL\\SearchBy\\Directives\\Directive::handleBuilder()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php",
          "line": 262,
          "call": "Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet::Nuwave\\Lighthouse\\Execution\\Arguments\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Execution/Arguments/ArgumentSet.php",
          "line": 130,
          "call": "Illuminate\\Support\\Collection::each()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Execution/Arguments/ArgumentSet.php",
          "line": 88,
          "call": "Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet::applyArgBuilderDirectives()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Pagination/PaginateDirective.php",
          "line": 129,
          "call": "Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet::enhanceBuilder()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Auth/CanDirective.php",
          "line": 151,
          "call": "Nuwave\\Lighthouse\\Pagination\\PaginateDirective::Nuwave\\Lighthouse\\Pagination\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Auth/GuardDirective.php",
          "line": 68,
          "call": "Nuwave\\Lighthouse\\Auth\\CanDirective::Nuwave\\Lighthouse\\Auth\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/ConvertEmptyStringsToNullDirective.php",
          "line": 48,
          "call": "Nuwave\\Lighthouse\\Auth\\GuardDirective::Nuwave\\Lighthouse\\Auth\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/DropArgsDirective.php",
          "line": 35,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\ConvertEmptyStringsToNullDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/RenameArgsDirective.php",
          "line": 35,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\DropArgsDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/SpreadDirective.php",
          "line": 34,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\RenameArgsDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/ArgTraversalDirective.php",
          "line": 27,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\SpreadDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Validation/ValidateDirective.php",
          "line": 50,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\ArgTraversalDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/ArgTraversalDirective.php",
          "line": 27,
          "call": "Nuwave\\Lighthouse\\Validation\\ValidateDirective::Nuwave\\Lighthouse\\Validation\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Directives/TrimDirective.php",
          "line": 54,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\ArgTraversalDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Schema/Factories/FieldFactory.php",
          "line": 97,
          "call": "Nuwave\\Lighthouse\\Schema\\Directives\\TrimDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "Nuwave\\Lighthouse\\Schema\\Factories\\FieldFactory::Nuwave\\Lighthouse\\Schema\\Factories\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
          "line": 268,
          "call": "GraphQL\\GraphQL::executeQuery()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
          "line": 203,
          "call": "Nuwave\\Lighthouse\\GraphQL::executeParsedQuery()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
          "line": 162,
          "call": "Nuwave\\Lighthouse\\GraphQL::parseAndExecuteQuery()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
          "line": 121,
          "call": "Nuwave\\Lighthouse\\GraphQL::executeOperation()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Support/Utils.php",
          "line": 99,
          "call": "Nuwave\\Lighthouse\\GraphQL::Nuwave\\Lighthouse\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
          "line": 120,
          "call": "Nuwave\\Lighthouse\\Support\\Utils::mapEach()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php",
          "line": 32,
          "call": "Nuwave\\Lighthouse\\GraphQL::executeOperationOrOperations()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
          "line": 48,
          "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::__invoke()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
          "line": 261,
          "call": "Illuminate\\Routing\\ControllerDispatcher::dispatch()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
          "line": 204,
          "call": "Illuminate\\Routing\\Route::runController()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
          "line": 725,
          "call": "Illuminate\\Routing\\Route::run()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 141,
          "call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}()"
        },
        {
          "file": "/var/www/html/src/Core/GraphQL/Middleware/LogQueryComplexity.php",
          "line": 30,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Core\\GraphQL\\Middleware\\LogQueryComplexity::handle()"
        },
        {
          "file": "/var/www/html/vendor/inspector-apm/inspector-laravel/src/Middleware/WebRequestMonitoring.php",
          "line": 35,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Inspector\\Laravel\\Middleware\\WebRequestMonitoring::handle()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Support/Http/Middleware/EnsureXHR.php",
          "line": 55,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\EnsureXHR::handle()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Support/Http/Middleware/AttemptAuthentication.php",
          "line": 34,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AttemptAuthentication::handle()"
        },
        {
          "file": "/var/www/html/vendor/nuwave/lighthouse/src/Support/Http/Middleware/AcceptJson.php",
          "line": 27,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 116,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
          "line": 726,
          "call": "Illuminate\\Pipeline\\Pipeline::then()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
          "line": 703,
          "call": "Illuminate\\Routing\\Router::runRouteWithinStack()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
          "line": 667,
          "call": "Illuminate\\Routing\\Router::runRoute()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
          "line": 656,
          "call": "Illuminate\\Routing\\Router::dispatchToRoute()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
          "line": 167,
          "call": "Illuminate\\Routing\\Router::dispatch()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 141,
          "call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php",
          "line": 45,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Sentry\\Laravel\\Http\\SetRequestIpMiddleware::handle()"
        },
        {
          "file": "/var/www/html/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php",
          "line": 42,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Sentry\\Laravel\\Http\\SetRequestMiddleware::handle()"
        },
        {
          "file": "/var/www/html/src/Core/Http/Middleware/ServerTimingMiddleware.php",
          "line": 44,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Core\\Http\\Middleware\\ServerTimingMiddleware::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
          "line": 21,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php",
          "line": 31,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
          "line": 21,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php",
          "line": 40,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
          "line": 27,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
          "line": 86,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php",
          "line": 62,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Http\\Middleware\\HandleCors::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php",
          "line": 39,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 180,
          "call": "Illuminate\\Http\\Middleware\\TrustProxies::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
          "line": 116,
          "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
          "line": 142,
          "call": "Illuminate\\Pipeline\\Pipeline::then()"
        },
        {
          "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
          "line": 111,
          "call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter()"
        },
        {
          "file": "/var/www/html/vendor/laravel/octane/src/ApplicationGateway.php",
          "line": 36,
          "call": "Illuminate\\Foundation\\Http\\Kernel::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/octane/src/Worker.php",
          "line": 92,
          "call": "Laravel\\Octane\\ApplicationGateway::handle()"
        },
        {
          "file": "/var/www/html/vendor/laravel/octane/bin/swoole-server",
          "line": 118,
          "call": "Laravel\\Octane\\Worker::handle()"
        },
        {
          "function": "{closure}()"
        },
        {
          "file": "/var/www/html/vendor/laravel/octane/bin/swoole-server",
          "line": 164,
          "call": "Swoole\\Server::start()"
        }
      ]
    }
  ]
}

First request is always successful. When cache is enable, everything is OK. My schema is super simple:

type Query {
users(
    filter: UserFilter @searchBy
  ): [User]
    @paginate(type: PAGINATOR)
    @softDeletes
    @guard
}

input UserFilter {
  id: ID
  firstname: String
  email: String
}

type User @model(class: "Modules\\User\\Entities\\User") {
  id: ID!
  firstname: String
  email: String
}

and the query is:

query {
  users(
    first: 51
    page: 1
    filter: {
      email: {
        like: "%gmail%"
      }
    }
  ) {
    paginatorInfo {
      count
      lastPage
      total
      hasMorePages
    }
    data {
      firstname
      email
    }
  }
}

All versions of framework, lighthouse and lara-asp are latest: 9.28, 5.58.2, 1.0.4.

Workflow update

  • New branch for releases
  • Releases should be created automatically
  • CHANGELOG file not needed (the main reason: impossible to edit while release), github releases probably will be enough
  • Some changelog generation fixes required (conventional-changelog/conventional-changelog#601 at least)
  • Will be better run tests for packages in main repo (very annoying to check all other repos)

Fails in combination with `Node` interface

In my application I am adding the Node interface via a custom directive:

    $nodeType = Parser::parseType(GlobalIdServiceProvider::NODE, [
      'noLocation' => true,
    ]);
    assert($nodeType instanceof NamedTypeNode);
    $objectType->interfaces[] = $nodeType;

Unfortunately, this causes issues in this call because the Node interface is not yet known:
image

The Node interface is only available later on:
https://github.com/nuwave/lighthouse/blob/d4ea07d61f1a0254bc979ab0d20ab33730edbd85/src/GlobalId/GlobalIdServiceProvider.php#L28-L37

Calculate complexity of `@searchBy`/`@sortBy` directive

Hello,
I think that searchBy/sortBy directives should calculate their complexity and add them to overall query complexity. This should prevent making exhausting queries to API, or allow to save more complex queries to debug purposes. Would be perfect, If we could read the complexity for sortby / searchby separately.

Filters stop working when using @rename directive

In my GraphQL schema a lot of fields are renamed using the @rename directive to make it less verbose since the project I am working on required a specific naming convention. When adding filters I found out that

This works but requires using the name of the database column and does not match the GraphQL naming convention since the field is called id inside the schema:

input AddressFiltersInput {
    AddressId: ID
}

In this case the generated SearchByConditionAddressFiltersInput looks like this:

input {
  allOf: [SearchByConditionAddressFiltersInput!]
  anyOf: [SearchByConditionAddressFiltersInput]!
  not: SearchByConditionAddressFiltersInput
  AddressId: SearchByScalarIDOrNull
}

But when adding the @rename directive the field that is using it is not included inside the generated SearchByConditionAddressFiltersInput:

input AddressFiltersInput {
    id: ID @rename(attribute: "AddressID")
}

The generated SearchByConditionAddressFiltersInput looks like this:

input {
  allOf: [SearchByConditionAddressFiltersInput!]
  anyOf: [SearchByConditionAddressFiltersInput]!
  not: SearchByConditionAddressFiltersInput
}

`SchemaPrinter` as default printer

  • Should provide a new Provider (or maybe a new package with autodiscovery), that can be used if needed;
  • Remove bindings for Settings (to force app to customize settings)
  • Remove DefaultSettings (seems not needed)

`release` action generates inconsistent commit hashes?

Need to investigate

- Upgrading lastdragon-ru/lara-asp-formatter (1.1.0 => 1.1.2): Checking out ede04c095d
    ede04c095d771cae6fa48a13121bb689dcb6ca5e is gone (history was rewritten?)
    Update of lastdragon-ru/lara-asp-formatter failed

Failed to execute git checkout 'ede04c095d771cae6fa48a13121bb689dcb6ca5e' -  
  - && git reset --hard 'ede04c095d771cae6fa48a13121bb689dcb6ca5e' --          
                                                                               
  fatal: reference is not a tree: ede04c095d771cae6fa48a13121bb689dcb6ca5e     
                                                                               
  It looks like the commit hash is not available in the repository, maybe the  
   tag was recreated? Run "composer update lastdragon-ru/lara-asp-formatter"   
  to resolve this.            

Make seeder behaviour more standard

  • Must not override app's DatabaseSeeder;
  • Must not grab all seeders from /seeders/*, instead, it should provide an option to set directory(ies) that should be included;
  • Better dependencies support

Automatically convert camel case fields to snake case

It would be great if there would be a way to automatically rename fields in the type that is used with the @searchBy directive to be in snake case. For example I would like to leave out the @rename column here:

input LegalEntityTypeFilters {
  title: String
  countryCode: String @rename(attribute: "country_code")
}

Or is there any nice way at the moment to already achieve it?

Run filters programmaticaly

In version before 1.0.0 I had trait:

<?php

declare(strict_types=1);

namespace Core\Abilities;

use Illuminate\Contracts\Container\Container;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Support\Collection;
use LastDragon_ru\LaraASP\GraphQL\SearchBy\SearchBuilder;

trait Filterable
{
    private Container $operatorsContainer;

    /**
     * @param EloquentBuilder<Model>|QueryBuilder $query
     * @param array<mixed> $filters
     * @return EloquentBuilder<Model>|QueryBuilder
     */
    public function scopeFilter(EloquentBuilder|QueryBuilder $query, array $filters): EloquentBuilder|QueryBuilder
    {
        $this->operatorsContainer = app(Container::class);
        $operators = (new Collection([
            0 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Logical\AllOf::class,
            1 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Logical\AnyOf::class,
            2 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Logical\Not::class,
            3 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Complex\Relation::class,
            4 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\Equal::class,
            5 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\NotEqual::class,
            6 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\In::class,
            7 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\NotIn::class,
            8 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\IsNull::class,
            9 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\IsNotNull::class,
            10 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\Like::class,
            11 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\NotLike::class,
            12 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\Contains::class,
            13 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\StartsWith::class,
            14 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\EndsWith::class,
            15 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\LessThan::class,
            16 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\LessThanOrEqual::class,
            17 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\GreaterThan::class,
            18 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\GreaterThanOrEqual::class,
            19 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\Between::class,
            20 => \LastDragon_ru\LaraASP\GraphQL\SearchBy\Operators\Comparison\NotBetween::class,
        ]))
            ->map(
                function (
                    string $operator
                ): \LastDragon_ru\LaraASP\GraphQL\SearchBy\Contracts\ComparisonOperator|\LastDragon_ru\LaraASP\GraphQL\SearchBy\Contracts\ComplexOperator|\LastDragon_ru\LaraASP\GraphQL\SearchBy\Contracts\LogicalOperator {
                    return $this->operatorsContainer->make($operator);
                }
            )
            ->all();

        return (new SearchBuilder($operators))->build($query, $filters);
    }
}

which allows me to run filters on models like this:

User::filter([
    'anyOf' => [
        [
            'allOf' => [
                [
                    'anyOf' => [
                        [
                            'email' => [
                                'like' => "%gmail%"
                            ]
                        ],
                        [
                            'email' => [
                                'like' => "%live%"
                            ]
                        ]
                    ]
                ],
            ]
        ]
    ]
]);

On version 1.0.0, filter mechanism was rewritten, and code stops work. Is there a possibility to run filters programmaticaly? I know it is "side functionality", but it is very helpful to store filters in database as JSON.

Detecting builder does not work with all built-in directives

Hi,

builder type detection for custom directives works perfect (#85), but current way of detecting builder based on directive class names is not flexible. In future, when lighthouse introduce some new directives, we will need to specify them in this package each time.

For example, lighthouse has @count directive which is used only to count items. It can be used inside type, but as a query too.

When I use schema like:

countCoupons(filter: CouponFilter @searchBy): Int @count

there is an error:

Impossible to determine builder type for `type Query { countCoupons(filter) }`.

  at vendor/lastdragon-ru/lara-asp-graphql/src/Builder/Directives/HandlerDirective.php:220
    216▕                 'document' => $documentAST,
    217▕             ]);
    218▕             $argSource   = $this->getFieldArgumentSource($manipulator, $parentType, $parentField, $argDefinition);
    219▕ 
  ➜ 220▕             throw new BuilderUnknown($argSource);
    221▕         }
    222▕ 
    223▕         // Converted?
    224▕         /** @var Manipulator $manipulator */

But we can't change internal lighthouse class so only way now to get it work is clone directive class to project.

`SchemaPrinter` must not load all existing types/directives through `Schema`/`DirectiveLocator`.

It doesn't work for custom schemas. There is no way to fix it until Lighthouse get rids of singletons :( The problem is

$map = $this->schema->getTypeMap();

so the getTypeMap() is (lazily) executed after printing and singletons reset, thus will refer to default (= application) schema.

Related to: #43, nuwave/lighthouse#273

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.