lastdragon-ru / lara-asp Goto Github PK
View Code? Open in Web Editor NEWAwesome Set of Packages for Laravel
License: MIT License
Awesome Set of Packages for Laravel
License: MIT License
While waiting for graphql/graphql-spec#300 (or something similar) would be good to have ability to print some directives (eg validation rules) in descriptions.
Only for Int
.
Single methods like Printer:printSchema()
probably not needed.
This will allow drop out Usages
+ list of operators. It is also required for #11
@searchBy
@sortBy
For example, Scout builder support only simple where
conditions so no reason to include allOf
/anyOf
/etc
Access to the Schema may be usefull for TypeFilter
, DirectiveFilter
(and maybe DirectiveResolver
) in some situations.
Related to #70
DatabaseSeeder
;/seeders/*
, instead, it should provide an option to set directory(ies) that should be included;Blocked by #17
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?
Hi,
like in title. That operations are possible in SQL, so there is no reason why these fields should not be available.
ASTBuilder
is singleton and will return cached instance, so useGraphQLSchema
will not have any effect
lara-asp/packages/graphql/src/Testing/GraphQLAssertions.php
Lines 217 to 224 in bbc8df8
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.
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
filter: CouponFilter @searchBy
from couponReport
- everything is fine.@report
to @all
in couponReport
query - everything is fine.@report
directive class to be exactly as @all
- does not workCouponReport
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 :(
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!]!
}
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.
Hi,
Your awesome package lara-asp-graphql-printer is not available on packagist (https://packagist.org/packages/lastdragon-ru/), so installing it is unnecessary complicated using
{
"type": "vcs",
"url": "https://github.com/LastDragon-ru/lara-asp-graphql-printer.git"
}
in composer.json
Waiting for nuwave/lighthouse#2052
It doesn't work for custom schemas. There is no way to fix it until Lighthouse get rids of singletons :( The problem is
so the getTypeMap()
is (lazily) executed after printing and singletons reset, thus will refer to default (= application) schema.
Related to: #43, nuwave/lighthouse#273
Would be nice to be able to print the graphql queries too.
dispatchAfterCommit
(laravel/framework#35422)Probably will be possible after #18
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).
type Query {
"""
@deprecated(
reason: "deprecated reason"
)
@codeDirective
@mock
"""
a: SchemaType
}
@sortBy
I hope it will simplify loading nested schemas.
Instead of/In addition to in config.
It is already possible to exclude type definitions, but not the whole type (definition, fields, arguments). Inspired by nuwave/lighthouse#2368
Settings
(to force app to customize settings)DefaultSettings
(seems not needed)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
}
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?
contains
and startsWith
the full-text index can be used (https://github.com/laravel/framework/releases/tag/v8.79.0, laravel/scout#564)whereHasIn
will be faster sometimesSomething else?
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.
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.
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:
The Node
interface is only available later on:
https://github.com/nuwave/lighthouse/blob/d4ea07d61f1a0254bc979ab0d20ab33730edbd85/src/GlobalId/GlobalIdServiceProvider.php#L28-L37
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.
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.
May be really useful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.