profile
viewpoint
Benedikt Franke spawnia @mll-lab Munich, Germany https://franke.tech I like to bring order to chaos. Structuring data, writing clean code and optimizing processes - I produce great results and learn along the way.

nuwave/lighthouse 1863

A framework for serving GraphQL from Laravel

digiaonline/graphql-php 210

A PHP7 implementation of the GraphQL specification.

nuwave/laravel-graphql-relay 45

This project is deprecated in favor of https://github.com/nuwave/lighthouse

nuwave/lighthouse-example 36

An example project using nuwave/lighthouse

nuwave/lighthouse-tutorial 21

This is the resulting source code of following the Lighthouse Tutorial

nuwave/lighthouse-ws 13

GraphQL Subscriptions for the Lighthouse (Laravel) package.

nuwave/lighthouse-docs 10

The docs for Lighthouse have moved to the main repository https://github.com/nuwave/lighthouse

spawnia/md-to-pdf 6

A web service for converting markdown to PDF

mll-lab/passwork-docker-compose 3

A Docker Compose setup for https://passwork.pro/

nuwave/lighthouse-todo-example 3

Consider the more recent https://github.com/nuwave/lighthouse-example

pull request commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

@shmax Thanks for the kind words. I admire your dedication and persistence on this matter and think it is great that you are willing to go the extra mile to really polish parts of the library. As I said before, I think your reworked approach to the Printer goes in the right direction. I will happily follow your progress in the other PR.

@vladar I reverted the changes to the point of your original review, replaced the assert(is_string()) with a @phpstan-ignore-next-line and added a PHPDoc to the printer. It's a small change, but it will save myself and others a bit of headache.

spawnia

comment created time in 13 hours

push eventspawnia/graphql-php

Benedikt Franke

commit sha 71cde83d7d1d88ed4fc622d8b02fb2d58ec03855

Remove unused imports

view details

push time in 13 hours

push eventspawnia/graphql-php

Benedikt Franke

commit sha 331fa68c25fa09623a50ffaedaea7bff35d566a5

Revert "Regenerate baseline" This reverts commit 1a5e7895

view details

Benedikt Franke

commit sha a927f26e0841254e62774cea1e4340057da77633

Revert "Remove misleading strong type hints, AST manipulation is wild" This reverts commit ca9f51f9

view details

Benedikt Franke

commit sha b7112ff053862babf6f1e1b633c67b08f84b081b

Revert "Remove strong type" This reverts commit 613bebc5

view details

Benedikt Franke

commit sha cdce62dc01eb2ccb988774adebe4923dda35e0b2

Add phpstan-ignore back in, add phpdoc

view details

push time in 14 hours

PR opened webonyx/graphql-php

Document how to prevent invisible types

https://github.com/webonyx/graphql-php/issues/99#issuecomment-655698238

+38 -0

0 comment

1 changed file

pr created time in 14 hours

create barnchspawnia/graphql-php

branch : prevent-invisible-types

created branch time in 14 hours

issue commentnuwave/lighthouse

Artisan command `lighthouse:ide-helper` is very slow

It takes about 2 minutes.

I am running in WSL2 with the project on a Windows filesystem, which probably explains the difference. The bottleneck definitely seems to be filesystem access.

We use haydenpierce/class-finder to look for schema directive classes. It accesses the filesystem a whole lot, probably more than necessary. See https://gitlab.com/hpierce1102/ClassFinder/-/issues/14.

spawnia

comment created time in 16 hours

pull request commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

@shmax Your approach in #697 is very good and I want to pursue it further.

If you want to use an intermediary format you can, but make a new format... don't just use the original and scramble its guts.

That would be a good solution too, but might not be worth the effort.

I do not intend or hope for the solution in this PR to be what we finally end up with, but I think it is a pragmatic solution that will work for now and improves upon what we have now on the following points:

  • Clarifies that there is duck-typing going on within the Printer
  • Satisfies PHPStan
  • Improves the accuracy of the actual AST, this directly benefits end users
spawnia

comment created time in 18 hours

push eventspawnia/graphql-php

Benedikt Franke

commit sha 1a5e78958aab0c2fcba69ac7fa96d9114a0aa29c

Regenerate baseline

view details

push time in 20 hours

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 class NamedTypeNode extends Node implements TypeNode     /** @var string */     public $kind = NodeKind::NAMED_TYPE; -    /** @var NameNode|string */+    /** @var NameNode */

Removed, added a PHPDocs that explains why for future reference.

spawnia

comment created time in 20 hours

push eventspawnia/graphql-php

Benedikt Franke

commit sha ca9f51f996b79b9f0764ebd87a9665897bf47cff

Remove misleading strong type hints, AST manipulation is wild

view details

push time in 20 hours

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        assert(is_string($node->name));

That works fine, PHPStan no longer complains since it has nothing to work with.

spawnia

comment created time in 21 hours

pull request commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

@vladar you make a good point. We should not try to shoehorn strong types in places where they are not accurate, sometimes PHP can be quite loose - especially when porting directly from graphql-js.

That said, i do prefer code that can be statically validated to be type safe, if the implementation allows for it. Not saying we must do it at all costs (e.g. performance matters more).

Should I remove all type hints from the Printer closures in this PR?

spawnia

comment created time in 21 hours

push eventspawnia/graphql-php

Benedikt Franke

commit sha 613bebc53f0c953d93f037e2b4acdfb3a65fafe6

Remove strong type

view details

push time in 21 hours

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        // @phpstan-ignore-next-line the printer works bottom up, so this is already a string here

Upgrade done.

spawnia

comment created time in a day

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        // @phpstan-ignore-next-line the printer works bottom up, so this is already a string here

Agreed, i added assert() instead.

spawnia

comment created time in a day

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 class NamedTypeNode extends Node implements TypeNode     /** @var string */     public $kind = NodeKind::NAMED_TYPE; -    /** @var NameNode|string */+    /** @var NameNode */

You are correct that other places are also affected. This is the only one where no string coercion happens, so PHPStan rightfully complains.

spawnia

comment created time in a day

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        assert(is_string($node->name));

otherwise we may need similar assertion in many other methods as well

I know what you mean. This conversion seems to be the only one affected, since there is no string concatination (and thus automatic type coercion) involved.

It seems imperfect to me, but pragmatically it looks like our best option for now. https://github.com/webonyx/graphql-php/pull/697 would be a clean fix, until then this PR improves things a bit at least.

spawnia

comment created time in a day

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        assert(is_string($node->name));

It satisfies Phpstan and is preferable to ignoring an error: If we change things around, it will trigger.

There is no runtime cost.

spawnia

comment created time in a day

issue commentwebonyx/graphql-php

Expose version in GraphQL class

The way symfony does it seems a bit tedious, maybe a slimmed down version with some helpers would be sufficient too.

const VERSION = '14.0.1';

public static function majorVersion(): int
{
    return explode(self::VERSION, '.')[0];
}

...
mcg-web

comment created time in a day

pull request commentwebonyx/graphql-php

Simplify getVisitFn

@shmax since you simplified the function, one uncovered line now is worse in terms of percentage.

I don't think we use arrays in place of a NodeList anymore - maybe we never have? There are a few courses of action we could take:

  1. Write an explicit test to cover it (might involve suppressing PHPStan errors in the setup code)
  2. Ignore the uncovered line (we might be able to exclude it explicitly?)
  3. Remove the functionality (we might do that in a next major, though, and go with 1. or 2. for now)
shmax

comment created time in a day

pull request commentAPIs-guru/graphql-over-http

Converting spec to spec-md format.

Is there a particular reason why we can not keep the spec in README.md for now?

mmatsa

comment created time in a day

delete branch webonyx/graphql-php

delete branch : update-phpstan

delete time in 2 days

pull request commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

Thanks for the thorough review @dlindenkreuz, I think we are making good progress towards an optimal and minimal solution.

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

+<?php++namespace App\GraphQL\Mutations;++use App\Models\User;+use GraphQL\Error\Error;+use Illuminate\Support\Facades\Auth;++class Login+{+    /**+     * @param  null  $_+     * @param  array<string, mixed>  $args+     */+    public function __invoke($_, array $args): User+    {+        $guard = Auth::guard();++        if( ! $guard->attempt($args)) {

I don't think it is necessary to future-proof against potential future renamings. Also, your implementation would also break if either the argument names or the model fields changed.

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

+<?php++namespace App\GraphQL\Mutations;++use App\Models\User;+use GraphQL\Error\Error;+use Illuminate\Support\Facades\Auth;++class Login+{+    /**+     * @param  null  $_+     * @param  array<string, mixed>  $args+     */+    public function __invoke($_, array $args): User+    {+        $guard = Auth::guard();

I'm returning the user straight away if it's already attached to the session, before attempting sign-in

What if an already authenticated user sends a different set of credentials to authenticate as another user? It seems counter-intuitive that their login will not change and the attempt will be silently discarded.

Is there a reason where the behaviour you proposed would be advantaguous?

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

+<?php++namespace App\GraphQL\Mutations;++use App\Models\User;+use GraphQL\Error\Error;+use Illuminate\Support\Facades\Auth;++class Login+{+    /**+     * @param  null  $_+     * @param  array<string, mixed>  $args+     */+    public function __invoke($_, array $args): User+    {+        $guard = Auth::guard();

Should be $guard = Auth::guard(config('sanctum.guard', 'web'));

I changed that bit because I could not find a setting guard within config/sanctum.php, is it hidden within the default settings?

What you are saying makes sense.

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

         'middleware' => [             \Nuwave\Lighthouse\Support\Http\Middleware\AcceptJson::class, +            \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,

I have this as first middleware. Not sure whether it matters.

The AcceptJson middleware will cause errors during EnsureFrontendRequestsAreStateful to be returned as JSON, which plays better with GraphQL Playground.

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

 class Kernel extends HttpKernel      * @var array<string, array<string|class-string>>      */     protected $middlewareGroups = [+        'web' => [+            \Illuminate\Cookie\Middleware\EncryptCookies::class,+            \Illuminate\Session\Middleware\StartSession::class,+            \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class,+        ],

I guess AddQueuedCookiesToResponse should be added, then. Or how about we just add Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful itself?

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

 scalar Date @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date") "A datetime string with format `Y-m-d H:i:s`, e.g. `2018-05-23 13:43:32`." scalar DateTime @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime") +type Mutation {+    "Log in to a new session and get the user."+    login(email: String!, password: String!): User!

In case an Exception is thrown, field execution is aborted anyways and an error is produced.

It is generally better for clients to be able to rely on a result being there. I am particularly keen on it since we use https://graphql-code-generator.com/ coupled with strict TypeScript options to enforce proper handling of nullability.

spawnia

comment created time in 2 days

Pull request review commentnuwave/lighthouse-example

Implement session based authentication with Sanctum

+<?php++return [++    /*+    |--------------------------------------------------------------------------+    | Stateful Domains+    |--------------------------------------------------------------------------+    |+    | Requests from the following domains / hosts will receive stateful API+    | authentication cookies. Typically, these should include your local+    | and production domains which access your API via a frontend SPA.+    |+    */++    'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', 'localhost,127.0.0.1,127.0.0.1:8000,::1')),

I left the default config as-is.

spawnia

comment created time in 2 days

pull request commentnuwave/lighthouse

docs: clarify usage with laravel sanctum, login / logout mutations

There is substantial amounts of setup that needs to be in place when starting from a bare-bones GraphQL only configuration.

Can you give me some feedback on https://github.com/nuwave/lighthouse-example/pull/9, how can that be improved?

dlindenkreuz

comment created time in 2 days

PR opened nuwave/lighthouse-example

Implement session based authentication with Sanctum

Not planning to merge into master, this PR is open just for discussion.

+467 -2

0 comment

14 changed files

pr created time in 2 days

create barnchnuwave/lighthouse-example

branch : sanctum

created branch time in 3 days

created tagmll-lab/laravel-graphql-playground

tagv2.2.1

Easily integrate GraphQL Playground into your Laravel project

created time in 3 days

release mll-lab/laravel-graphql-playground

v2.2.1

released time in 3 days

push eventmll-lab/laravel-graphql-playground

spawnia

commit sha e8527486485676a2c91eb9ac4a790c54c621822d

Fix loading removal by removing remaining bits

view details

push time in 3 days

push eventmll-lab/laravel-graphql-playground

spawnia

commit sha 22d3e7bcc34f9281b9dd79189218071668203d53

Clarify that request.credentials: same-origin is needed

view details

push time in 3 days

created tagmll-lab/laravel-graphql-playground

tagv2.2.0

Easily integrate GraphQL Playground into your Laravel project

created time in 3 days

release mll-lab/laravel-graphql-playground

v2.2.0

released time in 3 days

push eventmll-lab/laravel-graphql-playground

spawnia

commit sha 7489cff463211c1cfb31a863617c5629160a7a64

Clarify how to configure session authentication

view details

spawnia

commit sha 1d4ec2502189c67c9c46ec2e1b80aff9402c1367

Simplify view by excluding loading animation

view details

push time in 3 days

push eventmegawubs/lighthouse

spawnia

commit sha bd188aabd6d4c5589ef823b4237363b8a8d5470f

inline const

view details

push time in 3 days

push eventnuwave/lighthouse

spawnia

commit sha c10c922bb7ef30aab2dad6eeaf33d4515230db21

Add ErrorPool to allow for partial errors

view details

push time in 3 days

CommitCommentEvent

push eventmegawubs/lighthouse

Benedikt Franke

commit sha 63813c3a709ad050d8f577884640b195577438ee

Prevent silently overwriting types in `TypeRegistry` (#1361)

view details

Benedikt Franke

commit sha c3fe5567d30ec7192009a93efab6182f91c68b29

Prepare 4.13 release

view details

Benedikt Franke

commit sha 3d27a3ab120382e2ca5846d93f5f9430e3b9ff2a

Test BelongsTo relation to itself https://github.com/nuwave/lighthouse/issues/1365

view details

Benedikt Franke

commit sha ad17f9122cca2a477cca6c92bf1b35d4b0aa7c53

Apply fixes from StyleCI

view details

Benedikt Franke

commit sha 0b6ee1081d63b875bd638045dd97f6b2e33d53a4

Phpstan level 6 (#1368)

view details

Benedikt Franke

commit sha 568d1a6889d5ce6d392e24c1077e0471e7e70d2f

Pull primary key from arguments in `@update` before force filling them into the Model (#1377)

view details

spawnia

commit sha fc1d6f8edb8d6c0aa5dc3a8d91f3a2ea5bcc341b

Prepare CHANGELOG.md for 4.13.1

view details

lorado

commit sha 07f9126040d98c3a73c6e5faf1ea60039afd49ea

Write definitions for programmatically registered types to file with `lighthouse:ide-helper` (#1371)

view details

Benedikt Franke

commit sha 406ea06b3d8ba0943689d116eb3385193bcf431d

Add generated notice back in to GraphQL helper files

view details

Benedikt Franke

commit sha 8f276a310d569801e77ba6b8d00e7dea975d2daf

Apply fixes from StyleCI

view details

Benedikt Franke

commit sha 04d1e7721ef98e18b2d318c7cd8844b60417de26

Phpstan level 7 (#1380)

view details

Benedikt Franke

commit sha daa42c04a5add78384de80e47927d22e398a062b

Add example of a FieldMiddleware directive (#1388)

view details

Benedikt Franke

commit sha 07c26ef2b9d111f0724c2a80a618e42c5bd5d197

Fix the error message when using multiple exclusive directives on a single node (#1387)

view details

Benedikt Franke

commit sha 7dae89a80891290e453e184bd32b24955c1a7ab2

Clarify DefinedDirective deprecation (#1385)

view details

Benedikt Franke

commit sha 4c5670d489384578fdfd3f1abee88f3282f4b703

Useful autofixes from psalm (#1393)

view details

Benedikt Franke

commit sha f26c921ef317b2b538b3465bcdf45df176b2a32e

Allow passing additional headers to `multipartGraphQL` Lumen test helper too (#1395)

view details

Benedikt Franke

commit sha b0d1766036da6a54b3ffaaa5d72b87f2519e61c8

Fix phan issues (#1396)

view details

Yoshiharu Hirose

commit sha 301930b356faa63da681d564cbef41c7d312f2aa

Fix typo in lighthouse.php docblock (#1398)

view details

Benedikt Franke

commit sha 793f412531275d5573265d9318321d0e76196ae7

Rectify that `@orderBy`, `@whereConditions` and `@whereHasConditions` only work on field arguments (#1402)

view details

Benedikt Franke

commit sha e5496213bec43f67c969240e3419f3dda1fed75f

Make mass assignment behavior configurable through `force_fill` option in `lighthouse.php` (#1405)

view details

push time in 3 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 4eacbe18a88cf88fd574104838fc9dc8e3cf96db

Phpstan level 8 (#1394)

view details

Benedikt Franke

commit sha 6af1e380ea7e5214c46628058f74ad282fdf6f90

Add hint to visit `/graphql-playground` after installing mll-lab/laravel-graphql-playground Thanks @AlexeiaW Closes https://github.com/nuwave/lighthouse/pull/1432

view details

Ruslan

commit sha d70fb05f3528cb45e74e9bc6595915f25627e2a9

Additional information to run the IDE helper (#1433)

view details

Benedikt Franke

commit sha 50a6b714c40766ac308dc7e25d5b64291963ce3f

Add hint that lighthouse:ide-helper requires haydenpierce/class-finder to all docs versions

view details

Benedikt Franke

commit sha e80189830d4ceaf2d7c2d77b5749d7fbf91caee0

Document clearly that `@can` uses primary keys in `find` (#1437)

view details

Benedikt Franke

commit sha bd6fe94010ec39163fde169890aec3e00cf02933

Simplify field generator (#1434)

view details

wolfiton

commit sha 194ba12118e2c3ea46e7e13bf618980cfe553bfa

Defer apollo link update (#1442)

view details

Benedikt Franke

commit sha 0afa8633124bf151a76935e5e58b4e4e7157a179

Document that `@orderBy` will use `column` arg for inputs (#1444)

view details

Benedikt Franke

commit sha 7632c8b65deff3c5bd2fb416b06f9f308add660b

Document the lifecycle of an incoming GraphQL request (#1139)

view details

Benedikt Franke

commit sha 02f97d8c428835f4caf06777536eaa78873b9505

Fix batched paginated relation queries (#1447)

view details

Thiery Laverdure

commit sha 9d5222347eef6b3575b9f3ba0984156a222e8e2e

Add cache store option to config (#1446)

view details

Benedikt Franke

commit sha 35b852063d1368d479ff14198067e1fa7cef17a7

Release v4.15.0

view details

Andrew McLagan

commit sha 6a8b526bb52d84617aa34a6b3b3cfbeaefbd089e

Add user (#1453)

view details

Ruslan

commit sha 5807d531e09316f31c8283caeaf85460d02def7b

Add missing syntax highlighting in docs (#1455)

view details

Benedikt Franke

commit sha 1b8169dd51c5042cc338007bc15e86e219eb3e8b

Fix more missing syntax highlighting in docs Thanks @ruslan

view details

Thiery Laverdure

commit sha bc041641c50f194f0adc815043a812440978a07b

Add artisan command `lighthouse:cache` to compile GraphQL AST (#1451)

view details

Benedikt Franke

commit sha 6909a46a257cdde36046d157b6ffb4a679e0f1ef

Clean up commands (#1456)

view details

Benedikt Franke

commit sha 347aea65ea4c2dff84a5cfa219f10945f7581d78

Only post codecov status on pull requests

view details

Benedikt Franke

commit sha 429257b7025dc49fa50a671b34c1cc1be943037e

Add middleware to log incoming GraphQL queries (#1454)

view details

Benedikt Franke

commit sha 95bc697d4e000a705923fa285d961bc253332467

Separate testsuite for slow console tests (#1463)

view details

push time in 3 days

push eventnuwave/lighthouse-example

spawnia

commit sha b74b8954cda067b2118ff0252ac048d2a9500f0f

Update dependencies

view details

push time in 3 days

push eventnuwave/lighthouse-example

spawnia

commit sha 783d3c03e7fdb9cb1260ed2e74f70d3c75302cc4

Update dependencies

view details

push time in 3 days

push eventdlindenkreuz/lighthouse

Benedikt Franke

commit sha 95bc697d4e000a705923fa285d961bc253332467

Separate testsuite for slow console tests (#1463)

view details

Benedikt Franke

commit sha 8209bf1cd3aabb2f2ec66aca44cd884db486d5b5

Merge branch 'master' into sanctum-docs

view details

push time in 3 days

Pull request review commentnuwave/lighthouse

Added ability to handle relations in base where conditions

 public function handleBuilder($builder, $whereConditions)             return $builder;         } -        return $builder->whereHas(-            $this->getRelationName(),-            function ($builder) use ($whereConditions): void {-                // This extra nesting is required for the `OR` condition to work correctly.-                $builder->whereNested(-                    function ($builder) use ($whereConditions): void {-                        $this->handleWhereConditions($builder, $whereConditions);-                    }-                );-            }-        );+        return $this->handleWhereConditions($builder, [+            'HAS' => [+                'relation'  => $this->getRelationName(),+                // TODO: There should be a way to convert operator to its value from the code; WhereConditionsServiceProvider::DEFAULT_HAS_OPERATOR+                'operator'  => '>=',

Users are free to implement their own version of the Operator interface, with SQLOperator being just one possible implementation. The customs implementation can be bound through a service provider.

The implementation of the where directives must not assume that SQLOperator is used, that may not be the case. Thus, we must make no assumptions about the internal values of the operators.

alexey-krukover

comment created time in 3 days

Pull request review commentnuwave/lighthouse

Added ability to handle relations in base where conditions

 public function handleBuilder($builder, $whereConditions)             return $builder;         } -        return $builder->whereHas(-            $this->getRelationName(),-            function ($builder) use ($whereConditions): void {-                // This extra nesting is required for the `OR` condition to work correctly.-                $builder->whereNested(-                    function ($builder) use ($whereConditions): void {-                        $this->handleWhereConditions($builder, $whereConditions);-                    }-                );-            }-        );+        return $this->handleWhereConditions($builder, [

You call this function in a way that emulates what happens when being passed a GraphQL input, so you have to reconstruct this array shape. In terms of the layers of abstractions, that is moving the wrong way.

What should happen instead is:

  • there is one underlying method to call from PHP
  • another method converts the inputs from GraphQL to call that method
alexey-krukover

comment created time in 3 days

Pull request review commentnuwave/lighthouse

Added ability to handle relations in base where conditions

 public static function createWhereConditionsInputType(string $name, string $desc                  "A set of conditions that requires at least one condition to match."                 OR: [$name!]++                "A nested ord direct relation condition that create an amount criteria, and optionaly nested condition criteria."

I do not understand that description, grammar seems wrong too.

alexey-krukover

comment created time in 3 days

push eventalexey-krukover/lighthouse

Benedikt Franke

commit sha 4eacbe18a88cf88fd574104838fc9dc8e3cf96db

Phpstan level 8 (#1394)

view details

Benedikt Franke

commit sha 6af1e380ea7e5214c46628058f74ad282fdf6f90

Add hint to visit `/graphql-playground` after installing mll-lab/laravel-graphql-playground Thanks @AlexeiaW Closes https://github.com/nuwave/lighthouse/pull/1432

view details

Ruslan

commit sha d70fb05f3528cb45e74e9bc6595915f25627e2a9

Additional information to run the IDE helper (#1433)

view details

Benedikt Franke

commit sha 50a6b714c40766ac308dc7e25d5b64291963ce3f

Add hint that lighthouse:ide-helper requires haydenpierce/class-finder to all docs versions

view details

Benedikt Franke

commit sha e80189830d4ceaf2d7c2d77b5749d7fbf91caee0

Document clearly that `@can` uses primary keys in `find` (#1437)

view details

Benedikt Franke

commit sha bd6fe94010ec39163fde169890aec3e00cf02933

Simplify field generator (#1434)

view details

wolfiton

commit sha 194ba12118e2c3ea46e7e13bf618980cfe553bfa

Defer apollo link update (#1442)

view details

Benedikt Franke

commit sha 0afa8633124bf151a76935e5e58b4e4e7157a179

Document that `@orderBy` will use `column` arg for inputs (#1444)

view details

Benedikt Franke

commit sha 7632c8b65deff3c5bd2fb416b06f9f308add660b

Document the lifecycle of an incoming GraphQL request (#1139)

view details

Benedikt Franke

commit sha 02f97d8c428835f4caf06777536eaa78873b9505

Fix batched paginated relation queries (#1447)

view details

Thiery Laverdure

commit sha 9d5222347eef6b3575b9f3ba0984156a222e8e2e

Add cache store option to config (#1446)

view details

Benedikt Franke

commit sha 35b852063d1368d479ff14198067e1fa7cef17a7

Release v4.15.0

view details

Andrew McLagan

commit sha 6a8b526bb52d84617aa34a6b3b3cfbeaefbd089e

Add user (#1453)

view details

Ruslan

commit sha 5807d531e09316f31c8283caeaf85460d02def7b

Add missing syntax highlighting in docs (#1455)

view details

Benedikt Franke

commit sha 1b8169dd51c5042cc338007bc15e86e219eb3e8b

Fix more missing syntax highlighting in docs Thanks @ruslan

view details

Thiery Laverdure

commit sha bc041641c50f194f0adc815043a812440978a07b

Add artisan command `lighthouse:cache` to compile GraphQL AST (#1451)

view details

Benedikt Franke

commit sha 6909a46a257cdde36046d157b6ffb4a679e0f1ef

Clean up commands (#1456)

view details

Benedikt Franke

commit sha 347aea65ea4c2dff84a5cfa219f10945f7581d78

Only post codecov status on pull requests

view details

Benedikt Franke

commit sha 429257b7025dc49fa50a671b34c1cc1be943037e

Add middleware to log incoming GraphQL queries (#1454)

view details

Benedikt Franke

commit sha 95bc697d4e000a705923fa285d961bc253332467

Separate testsuite for slow console tests (#1463)

view details

push time in 3 days

Pull request review commentnuwave/lighthouse

Added ability to handle relations in base where conditions

 public static function definition(): string     /**      * @param  \Illuminate\Database\Eloquent\Builder  $builder  The builder used to resolve the field.      * @param  mixed  $whereConditions The client given conditions-     * @return \Illuminate\Database\Eloquent\Builder  The modified builder.+     * @return \Illuminate\Database\Eloquent\Builder | \Illuminate\Database\Query\Builder  The modified builder.

You can use a /** @var */ PHPDoc to assert the result of handleWhereConditions is a specific type.

alexey-krukover

comment created time in 3 days

issue commentwebonyx/graphql-php

Parser::__callStatic is incorrectly typed

Nice to see someone actually use the partial parse functions.

Converting them to non-magical methods would definitely be the way to go, but involves an unfortunate amount of boilerplate and typing. Something for a rainy, uninspired weekend.

unclecheese

comment created time in 3 days

push eventspawnia/graphql-php

spawnia

commit sha 264b77606247b2db11e9e50ad7bbad6c94e7d3ae

Add test for function that returns NodeList and annotate correctly Fix https://github.com/webonyx/graphql-php/issues/698

view details

push time in 3 days

push eventspawnia/fedora-setup

spawnia

commit sha 149055b95a79f197e151606fb46c3c3462314eb9

Add php-xdebug

view details

push time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

 public function testMaintainsTypeInfoDuringEdit() : void                                 'directives'   => $node->directives,                                 'selectionSet' => new SelectionSetNode([                                     'kind'       => 'SelectionSet',-                                    'selections' => [new FieldNode([+                                    'selections' => NodeList::create([new FieldNode([
                                    'selections' => new NodeList([new FieldNode([
shmax

comment created time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

 public static function doPrint($ast)         static $instance;         $instance = $instance ?? new static(); +        if (! $ast instanceof Node) {+            throw new Exception('Invalid AST Node: ' . json_encode($ast));+        }+         return $instance->printAST($ast);     }      protected function __construct()     {     } -    public function printAST($ast)+    public function printAST(Node $node)     {-        return Visitor::visit(-            $ast,-            [-                'leave' => [-                    NodeKind::NAME => static function (NameNode $node) : string {-                        return '' . $node->value;-                    },--                    NodeKind::VARIABLE => static function (VariableNode $node) : string {-                        return '$' . $node->name;-                    },--                    NodeKind::DOCUMENT => function (DocumentNode $node) : string {-                        return $this->join($node->definitions, "\n\n") . "\n";-                    },--                    NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) {-                        $op           = $node->operation;-                        $name         = $node->name;-                        $varDefs      = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');-                        $directives   = $this->join($node->directives, ' ');-                        $selectionSet = $node->selectionSet;--                        // Anonymous queries with no directives or variable definitions can use-                        // the query short form.-                        return $name === null && ! $directives && ! $varDefs && $op === 'query'-                            ? $selectionSet-                            : $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');-                    },--                    NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) : string {-                        return $node->variable-                            . ': '-                            . $node->type-                            . $this->wrap(' = ', $node->defaultValue)-                            . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::SELECTION_SET => function (SelectionSetNode $node) {-                        return $this->block($node->selections);-                    },--                    NodeKind::FIELD => function (FieldNode $node) {-                        return $this->join(-                            [-                                $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap(-                                    '(',-                                    $this->join($node->arguments, ', '),-                                    ')'-                                ),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::ARGUMENT => static function (ArgumentNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) : string {-                        return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) {-                        return $this->join(-                            [-                                '...',-                                $this->wrap('on ', $node->typeCondition),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) : string {-                        // Note: fragment variable definitions are experimental and may be changed or removed in the future.-                        return sprintf('fragment %s', $node->name)-                            . $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')')-                            . sprintf(' on %s ', $node->typeCondition)-                            . $this->wrap('', $this->join($node->directives, ' '), ' ')-                            . $node->selectionSet;-                    },--                    NodeKind::INT => static function (IntValueNode $node) {-                        return $node->value;-                    },--                    NodeKind::FLOAT => static function (FloatValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::STRING => function (StringValueNode $node, $key) {-                        if ($node->block) {-                            return $this->printBlockString($node->value, $key === 'description');-                        }--                        return json_encode($node->value);-                    },--                    NodeKind::BOOLEAN => static function (BooleanValueNode $node) {-                        return $node->value ? 'true' : 'false';-                    },--                    NodeKind::NULL => static function (NullValueNode $node) : string {-                        return 'null';-                    },--                    NodeKind::ENUM => static function (EnumValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::LST => function (ListValueNode $node) : string {-                        return '[' . $this->join($node->values, ', ') . ']';-                    },--                    NodeKind::OBJECT => function (ObjectValueNode $node) : string {-                        return '{' . $this->join($node->fields, ', ') . '}';-                    },--                    NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::DIRECTIVE => function (DirectiveNode $node) : string {-                        return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');-                    },--                    NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {-                        return $node->name;-                    },--                    NodeKind::LIST_TYPE => static function (ListTypeNode $node) : string {-                        return '[' . $node->type . ']';-                    },--                    NodeKind::NON_NULL_TYPE => static function (NonNullTypeNode $node) : string {-                        return $node->type . '!';-                    },--                    NodeKind::SCHEMA_DEFINITION => function (SchemaDefinitionNode $def) {-                        return $this->join(-                            [-                                'schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OPERATION_TYPE_DEFINITION => static function (OperationTypeDefinitionNode $def) : string {-                        return $def->operation . ': ' . $def->type;-                    },--                    NodeKind::SCALAR_TYPE_DEFINITION => $this->addDescription(function (ScalarTypeDefinitionNode $def) {-                        return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::OBJECT_TYPE_DEFINITION => $this->addDescription(function (ObjectTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::FIELD_DEFINITION => $this->addDescription(function (FieldDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });--                        return $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n)"))-                            . ': ' . $def->type-                            . $this->wrap(' ', $this->join($def->directives, ' '));-                    }),--                    NodeKind::INPUT_VALUE_DEFINITION => $this->addDescription(function (InputValueDefinitionNode $def) {-                        return $this->join(-                            [-                                $def->name . ': ' . $def->type,-                                $this->wrap('= ', $def->defaultValue),-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::INTERFACE_TYPE_DEFINITION => $this->addDescription(-                        function (InterfaceTypeDefinitionNode $def) {-                            return $this->join(-                                [-                                    'interface',-                                    $def->name,-                                    $this->join($def->directives, ' '),-                                    $this->block($def->fields),-                                ],-                                ' '-                            );-                        }-                    ),--                    NodeKind::UNION_TYPE_DEFINITION => $this->addDescription(function (UnionTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_TYPE_DEFINITION => $this->addDescription(function (EnumTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_VALUE_DEFINITION => $this->addDescription(function (EnumValueDefinitionNode $def) {-                        return $this->join([$def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $this->addDescription(function (-                        InputObjectTypeDefinitionNode $def-                    ) {-                        return $this->join(-                            [-                                'input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::SCHEMA_EXTENSION => function (SchemaTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::SCALAR_TYPE_EXTENSION => function (ScalarTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend scalar',-                                $def->name,-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OBJECT_TYPE_EXTENSION => function (ObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },--                    NodeKind::INTERFACE_TYPE_EXTENSION => function (InterfaceTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend interface',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+        return $this->p($node);+    } -                    NodeKind::UNION_TYPE_EXTENSION => function (UnionTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    },+    /**+     * @return array<Node>+     */+    protected function listToArray(?NodeList $list) : array+    {+        return isset($list) ? iterator_to_array($list) : [];+    } -                    NodeKind::ENUM_TYPE_EXTENSION => function (EnumTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    },+    protected function printList(?NodeList $list, $separator = '') : string+    {+        return $this->printArray($this->listToArray($list), $separator);+    } -                    NodeKind::INPUT_OBJECT_TYPE_EXTENSION => function (InputObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+    protected function printListBlock(?NodeList $list) : string+    {+        return $this->block(array_map(function ($item) : string {+            return $this->p($item);+        }, $this->listToArray($list)));+    } -                    NodeKind::DIRECTIVE_DEFINITION => $this->addDescription(function (DirectiveDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });+    /**+     * @param array<Node> $list+     */+    protected function printArray(array $list, string $separator = '') : string+    {+        return $this->join(array_map(function ($item) : string {+            return $this->p($item);+        }, $list), $separator);+    } -                        return 'directive @'-                            . $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n"))-                            . ($def->repeatable ? ' repeatable' : '')-                            . ' on ' . $this->join($def->locations, ' | ');-                    }),-                ],-            ]-        );+    public function p(?Node $node, bool $isDescription = false) : string+    {+        $res = '';+        if ($node === null) {+            return '';+        }+        switch (true) {+            case $node instanceof ArgumentNode:+                return $this->p($node->name) . ': ' . $this->p($node->value);+            case $node instanceof BooleanValueNode:+                return $node->value ? 'true' : 'false';+            case $node instanceof DirectiveDefinitionNode:+                $argStrings = array_map(function ($item) : string {+                    return $this->p($item);+                }, $this->listToArray($node->arguments));+                $noIndent   = Utils::every($argStrings, static function (string $arg) : bool {+                    return strpos($arg, "\n") === false;+                });++                return $this->addDescription($node->description, 'directive @'+                    . $this->p($node->name)+                    . ($noIndent+                        ? $this->wrap('(', $this->join($argStrings, ', '), ')')+                        : $this->wrap("(\n", $this->indent($this->join($argStrings, "\n")), "\n"))+                    . ($node->repeatable ? ' repeatable' : '')+                    . ' on ' . $this->printArray($node->locations, ' | '));+            case $node instanceof DirectiveNode:+                return '@' . $this->p($node->name) . $this->wrap('(', $this->printList($node->arguments, ', '), ')');+            case $node instanceof DocumentNode:+                return $this->printList($node->definitions, "\n\n") . "\n";+            case $node instanceof EnumTypeDefinitionNode:+                return $this->addDescription($node->description, $this->join(+                    [+                        'enum',+                        $this->p($node->name),+                        $this->printList($node->directives, ' '),+                        $this->printListBlock($node->values),+                    ],+                    ' '+                ));+            case $node instanceof EnumTypeExtensionNode:+                return $this->join(+                    [+                        'extend enum',+                        $this->p($node->name),+                        $this->printList($node->directives, ' '),+                        $this->printListBlock($node->values),+                    ],+                    ' '+                );+            case $node instanceof EnumValueDefinitionNode:+                return $this->addDescription(+                    $node->description,+                    $this->join([$this->p($node->name), $this->printList($node->directives, ' ')], ' ')+                );+            case $node instanceof EnumValueNode:+                return $node->value;+            case $node instanceof FieldDefinitionNode:+                $argStrings = array_map(function ($item) : string {+                    return $this->p($item);+                }, $this->listToArray($node->arguments));+                $noIndent   = Utils::every($argStrings, static function (string $arg) : bool {+                    return strpos($arg, "\n") === false;+                });++                return $this->addDescription(+                    $node->description,+                    $this->p($node->name)+                    . ($noIndent+                        ? $this->wrap('(', $this->join($argStrings, ', '), ')')+                        : $this->wrap("(\n", $this->indent($this->join($argStrings, "\n")), "\n)"))+                    . ': ' . $this->p($node->type)+                    . $this->wrap(' ', $this->printList($node->directives, ' '))+                );+            case $node instanceof FieldNode:+                return $this->join(+                    [+                        $this->wrap('', $node->alias->value ?? null, ': ') . $this->p($node->name) . $this->wrap(+                            '(',+                            $this->printList($node->arguments, ', '),+                            ')'+                        ),+                        $this->printList($node->directives, ' '),+                        $this->p($node->selectionSet),+                    ],+                    ' '+                );+            case $node instanceof FloatValueNode:+                return $node->value;+            case $node instanceof FragmentDefinitionNode:+                // Note: fragment variable definitions are experimental and may be changed or removed in the future.+                return sprintf('fragment %s', $this->p($node->name))
                return 'fragment ' . $this->p($node->name)

I think that would be much more readable. (Full disclosure: I despise sprintf :shrug:)

shmax

comment created time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

 public static function doPrint($ast)         static $instance;         $instance = $instance ?? new static(); +        if (! $ast instanceof Node) {+            throw new Exception('Invalid AST Node: ' . json_encode($ast));+        }+         return $instance->printAST($ast);     }      protected function __construct()     {     } -    public function printAST($ast)+    public function printAST(Node $node)     {-        return Visitor::visit(-            $ast,-            [-                'leave' => [-                    NodeKind::NAME => static function (NameNode $node) : string {-                        return '' . $node->value;-                    },--                    NodeKind::VARIABLE => static function (VariableNode $node) : string {-                        return '$' . $node->name;-                    },--                    NodeKind::DOCUMENT => function (DocumentNode $node) : string {-                        return $this->join($node->definitions, "\n\n") . "\n";-                    },--                    NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) {-                        $op           = $node->operation;-                        $name         = $node->name;-                        $varDefs      = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');-                        $directives   = $this->join($node->directives, ' ');-                        $selectionSet = $node->selectionSet;--                        // Anonymous queries with no directives or variable definitions can use-                        // the query short form.-                        return $name === null && ! $directives && ! $varDefs && $op === 'query'-                            ? $selectionSet-                            : $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');-                    },--                    NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) : string {-                        return $node->variable-                            . ': '-                            . $node->type-                            . $this->wrap(' = ', $node->defaultValue)-                            . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::SELECTION_SET => function (SelectionSetNode $node) {-                        return $this->block($node->selections);-                    },--                    NodeKind::FIELD => function (FieldNode $node) {-                        return $this->join(-                            [-                                $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap(-                                    '(',-                                    $this->join($node->arguments, ', '),-                                    ')'-                                ),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::ARGUMENT => static function (ArgumentNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) : string {-                        return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) {-                        return $this->join(-                            [-                                '...',-                                $this->wrap('on ', $node->typeCondition),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) : string {-                        // Note: fragment variable definitions are experimental and may be changed or removed in the future.-                        return sprintf('fragment %s', $node->name)-                            . $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')')-                            . sprintf(' on %s ', $node->typeCondition)-                            . $this->wrap('', $this->join($node->directives, ' '), ' ')-                            . $node->selectionSet;-                    },--                    NodeKind::INT => static function (IntValueNode $node) {-                        return $node->value;-                    },--                    NodeKind::FLOAT => static function (FloatValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::STRING => function (StringValueNode $node, $key) {-                        if ($node->block) {-                            return $this->printBlockString($node->value, $key === 'description');-                        }--                        return json_encode($node->value);-                    },--                    NodeKind::BOOLEAN => static function (BooleanValueNode $node) {-                        return $node->value ? 'true' : 'false';-                    },--                    NodeKind::NULL => static function (NullValueNode $node) : string {-                        return 'null';-                    },--                    NodeKind::ENUM => static function (EnumValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::LST => function (ListValueNode $node) : string {-                        return '[' . $this->join($node->values, ', ') . ']';-                    },--                    NodeKind::OBJECT => function (ObjectValueNode $node) : string {-                        return '{' . $this->join($node->fields, ', ') . '}';-                    },--                    NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::DIRECTIVE => function (DirectiveNode $node) : string {-                        return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');-                    },--                    NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {-                        return $node->name;-                    },--                    NodeKind::LIST_TYPE => static function (ListTypeNode $node) : string {-                        return '[' . $node->type . ']';-                    },--                    NodeKind::NON_NULL_TYPE => static function (NonNullTypeNode $node) : string {-                        return $node->type . '!';-                    },--                    NodeKind::SCHEMA_DEFINITION => function (SchemaDefinitionNode $def) {-                        return $this->join(-                            [-                                'schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OPERATION_TYPE_DEFINITION => static function (OperationTypeDefinitionNode $def) : string {-                        return $def->operation . ': ' . $def->type;-                    },--                    NodeKind::SCALAR_TYPE_DEFINITION => $this->addDescription(function (ScalarTypeDefinitionNode $def) {-                        return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::OBJECT_TYPE_DEFINITION => $this->addDescription(function (ObjectTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::FIELD_DEFINITION => $this->addDescription(function (FieldDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });--                        return $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n)"))-                            . ': ' . $def->type-                            . $this->wrap(' ', $this->join($def->directives, ' '));-                    }),--                    NodeKind::INPUT_VALUE_DEFINITION => $this->addDescription(function (InputValueDefinitionNode $def) {-                        return $this->join(-                            [-                                $def->name . ': ' . $def->type,-                                $this->wrap('= ', $def->defaultValue),-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::INTERFACE_TYPE_DEFINITION => $this->addDescription(-                        function (InterfaceTypeDefinitionNode $def) {-                            return $this->join(-                                [-                                    'interface',-                                    $def->name,-                                    $this->join($def->directives, ' '),-                                    $this->block($def->fields),-                                ],-                                ' '-                            );-                        }-                    ),--                    NodeKind::UNION_TYPE_DEFINITION => $this->addDescription(function (UnionTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_TYPE_DEFINITION => $this->addDescription(function (EnumTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_VALUE_DEFINITION => $this->addDescription(function (EnumValueDefinitionNode $def) {-                        return $this->join([$def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $this->addDescription(function (-                        InputObjectTypeDefinitionNode $def-                    ) {-                        return $this->join(-                            [-                                'input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::SCHEMA_EXTENSION => function (SchemaTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::SCALAR_TYPE_EXTENSION => function (ScalarTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend scalar',-                                $def->name,-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OBJECT_TYPE_EXTENSION => function (ObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },--                    NodeKind::INTERFACE_TYPE_EXTENSION => function (InterfaceTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend interface',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+        return $this->p($node);+    } -                    NodeKind::UNION_TYPE_EXTENSION => function (UnionTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    },+    /**+     * @return array<Node>+     */+    protected function listToArray(?NodeList $list) : array+    {+        return isset($list) ? iterator_to_array($list) : [];+    } -                    NodeKind::ENUM_TYPE_EXTENSION => function (EnumTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    },+    protected function printList(?NodeList $list, $separator = '') : string+    {+        return $this->printArray($this->listToArray($list), $separator);+    } -                    NodeKind::INPUT_OBJECT_TYPE_EXTENSION => function (InputObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+    protected function printListBlock(?NodeList $list) : string+    {+        return $this->block(array_map(function ($item) : string {+            return $this->p($item);+        }, $this->listToArray($list)));+    } -                    NodeKind::DIRECTIVE_DEFINITION => $this->addDescription(function (DirectiveDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });+    /**+     * @param array<Node> $list+     */+    protected function printArray(array $list, string $separator = '') : string+    {+        return $this->join(array_map(function ($item) : string {+            return $this->p($item);+        }, $list), $separator);+    } -                        return 'directive @'-                            . $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n"))-                            . ($def->repeatable ? ' repeatable' : '')-                            . ' on ' . $this->join($def->locations, ' | ');-                    }),-                ],-            ]-        );+    public function p(?Node $node, bool $isDescription = false) : string+    {+        $res = '';+        if ($node === null) {+            return '';+        }+        switch (true) {+            case $node instanceof ArgumentNode:+                return $this->p($node->name) . ': ' . $this->p($node->value);+            case $node instanceof BooleanValueNode:+                return $node->value ? 'true' : 'false';+            case $node instanceof DirectiveDefinitionNode:+                $argStrings = array_map(function ($item) : string {

What is the type of $item?

shmax

comment created time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

 public static function doPrint($ast)         static $instance;         $instance = $instance ?? new static(); +        if (! $ast instanceof Node) {+            throw new Exception('Invalid AST Node: ' . json_encode($ast));+        }+         return $instance->printAST($ast);     }      protected function __construct()     {     } -    public function printAST($ast)+    public function printAST(Node $node)     {-        return Visitor::visit(-            $ast,-            [-                'leave' => [-                    NodeKind::NAME => static function (NameNode $node) : string {-                        return '' . $node->value;-                    },--                    NodeKind::VARIABLE => static function (VariableNode $node) : string {-                        return '$' . $node->name;-                    },--                    NodeKind::DOCUMENT => function (DocumentNode $node) : string {-                        return $this->join($node->definitions, "\n\n") . "\n";-                    },--                    NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) {-                        $op           = $node->operation;-                        $name         = $node->name;-                        $varDefs      = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');-                        $directives   = $this->join($node->directives, ' ');-                        $selectionSet = $node->selectionSet;--                        // Anonymous queries with no directives or variable definitions can use-                        // the query short form.-                        return $name === null && ! $directives && ! $varDefs && $op === 'query'-                            ? $selectionSet-                            : $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');-                    },--                    NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) : string {-                        return $node->variable-                            . ': '-                            . $node->type-                            . $this->wrap(' = ', $node->defaultValue)-                            . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::SELECTION_SET => function (SelectionSetNode $node) {-                        return $this->block($node->selections);-                    },--                    NodeKind::FIELD => function (FieldNode $node) {-                        return $this->join(-                            [-                                $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap(-                                    '(',-                                    $this->join($node->arguments, ', '),-                                    ')'-                                ),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::ARGUMENT => static function (ArgumentNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) : string {-                        return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) {-                        return $this->join(-                            [-                                '...',-                                $this->wrap('on ', $node->typeCondition),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) : string {-                        // Note: fragment variable definitions are experimental and may be changed or removed in the future.-                        return sprintf('fragment %s', $node->name)-                            . $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')')-                            . sprintf(' on %s ', $node->typeCondition)-                            . $this->wrap('', $this->join($node->directives, ' '), ' ')-                            . $node->selectionSet;-                    },--                    NodeKind::INT => static function (IntValueNode $node) {-                        return $node->value;-                    },--                    NodeKind::FLOAT => static function (FloatValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::STRING => function (StringValueNode $node, $key) {-                        if ($node->block) {-                            return $this->printBlockString($node->value, $key === 'description');-                        }--                        return json_encode($node->value);-                    },--                    NodeKind::BOOLEAN => static function (BooleanValueNode $node) {-                        return $node->value ? 'true' : 'false';-                    },--                    NodeKind::NULL => static function (NullValueNode $node) : string {-                        return 'null';-                    },--                    NodeKind::ENUM => static function (EnumValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::LST => function (ListValueNode $node) : string {-                        return '[' . $this->join($node->values, ', ') . ']';-                    },--                    NodeKind::OBJECT => function (ObjectValueNode $node) : string {-                        return '{' . $this->join($node->fields, ', ') . '}';-                    },--                    NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::DIRECTIVE => function (DirectiveNode $node) : string {-                        return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');-                    },--                    NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {-                        return $node->name;-                    },--                    NodeKind::LIST_TYPE => static function (ListTypeNode $node) : string {-                        return '[' . $node->type . ']';-                    },--                    NodeKind::NON_NULL_TYPE => static function (NonNullTypeNode $node) : string {-                        return $node->type . '!';-                    },--                    NodeKind::SCHEMA_DEFINITION => function (SchemaDefinitionNode $def) {-                        return $this->join(-                            [-                                'schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OPERATION_TYPE_DEFINITION => static function (OperationTypeDefinitionNode $def) : string {-                        return $def->operation . ': ' . $def->type;-                    },--                    NodeKind::SCALAR_TYPE_DEFINITION => $this->addDescription(function (ScalarTypeDefinitionNode $def) {-                        return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::OBJECT_TYPE_DEFINITION => $this->addDescription(function (ObjectTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::FIELD_DEFINITION => $this->addDescription(function (FieldDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });--                        return $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n)"))-                            . ': ' . $def->type-                            . $this->wrap(' ', $this->join($def->directives, ' '));-                    }),--                    NodeKind::INPUT_VALUE_DEFINITION => $this->addDescription(function (InputValueDefinitionNode $def) {-                        return $this->join(-                            [-                                $def->name . ': ' . $def->type,-                                $this->wrap('= ', $def->defaultValue),-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::INTERFACE_TYPE_DEFINITION => $this->addDescription(-                        function (InterfaceTypeDefinitionNode $def) {-                            return $this->join(-                                [-                                    'interface',-                                    $def->name,-                                    $this->join($def->directives, ' '),-                                    $this->block($def->fields),-                                ],-                                ' '-                            );-                        }-                    ),--                    NodeKind::UNION_TYPE_DEFINITION => $this->addDescription(function (UnionTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_TYPE_DEFINITION => $this->addDescription(function (EnumTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_VALUE_DEFINITION => $this->addDescription(function (EnumValueDefinitionNode $def) {-                        return $this->join([$def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $this->addDescription(function (-                        InputObjectTypeDefinitionNode $def-                    ) {-                        return $this->join(-                            [-                                'input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::SCHEMA_EXTENSION => function (SchemaTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::SCALAR_TYPE_EXTENSION => function (ScalarTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend scalar',-                                $def->name,-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OBJECT_TYPE_EXTENSION => function (ObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },--                    NodeKind::INTERFACE_TYPE_EXTENSION => function (InterfaceTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend interface',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+        return $this->p($node);+    } -                    NodeKind::UNION_TYPE_EXTENSION => function (UnionTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    },+    /**+     * @return array<Node>+     */+    protected function listToArray(?NodeList $list) : array+    {+        return isset($list) ? iterator_to_array($list) : [];+    } -                    NodeKind::ENUM_TYPE_EXTENSION => function (EnumTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    },+    protected function printList(?NodeList $list, $separator = '') : string+    {+        return $this->printArray($this->listToArray($list), $separator);+    } -                    NodeKind::INPUT_OBJECT_TYPE_EXTENSION => function (InputObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+    protected function printListBlock(?NodeList $list) : string+    {+        return $this->block(array_map(function ($item) : string {+            return $this->p($item);+        }, $this->listToArray($list)));+    } -                    NodeKind::DIRECTIVE_DEFINITION => $this->addDescription(function (DirectiveDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });+    /**+     * @param array<Node> $list+     */+    protected function printArray(array $list, string $separator = '') : string+    {+        return $this->join(array_map(function ($item) : string {+            return $this->p($item);+        }, $list), $separator);+    } -                        return 'directive @'-                            . $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n"))-                            . ($def->repeatable ? ' repeatable' : '')-                            . ' on ' . $this->join($def->locations, ' | ');-                    }),-                ],-            ]-        );+    public function p(?Node $node, bool $isDescription = false) : string

Or printNode

shmax

comment created time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

 public static function doPrint($ast)         static $instance;         $instance = $instance ?? new static(); +        if (! $ast instanceof Node) {+            throw new Exception('Invalid AST Node: ' . json_encode($ast));+        }+         return $instance->printAST($ast);     }      protected function __construct()     {     } -    public function printAST($ast)+    public function printAST(Node $node)     {-        return Visitor::visit(-            $ast,-            [-                'leave' => [-                    NodeKind::NAME => static function (NameNode $node) : string {-                        return '' . $node->value;-                    },--                    NodeKind::VARIABLE => static function (VariableNode $node) : string {-                        return '$' . $node->name;-                    },--                    NodeKind::DOCUMENT => function (DocumentNode $node) : string {-                        return $this->join($node->definitions, "\n\n") . "\n";-                    },--                    NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) {-                        $op           = $node->operation;-                        $name         = $node->name;-                        $varDefs      = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');-                        $directives   = $this->join($node->directives, ' ');-                        $selectionSet = $node->selectionSet;--                        // Anonymous queries with no directives or variable definitions can use-                        // the query short form.-                        return $name === null && ! $directives && ! $varDefs && $op === 'query'-                            ? $selectionSet-                            : $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');-                    },--                    NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $node) : string {-                        return $node->variable-                            . ': '-                            . $node->type-                            . $this->wrap(' = ', $node->defaultValue)-                            . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::SELECTION_SET => function (SelectionSetNode $node) {-                        return $this->block($node->selections);-                    },--                    NodeKind::FIELD => function (FieldNode $node) {-                        return $this->join(-                            [-                                $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap(-                                    '(',-                                    $this->join($node->arguments, ', '),-                                    ')'-                                ),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::ARGUMENT => static function (ArgumentNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) : string {-                        return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));-                    },--                    NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) {-                        return $this->join(-                            [-                                '...',-                                $this->wrap('on ', $node->typeCondition),-                                $this->join($node->directives, ' '),-                                $node->selectionSet,-                            ],-                            ' '-                        );-                    },--                    NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) : string {-                        // Note: fragment variable definitions are experimental and may be changed or removed in the future.-                        return sprintf('fragment %s', $node->name)-                            . $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')')-                            . sprintf(' on %s ', $node->typeCondition)-                            . $this->wrap('', $this->join($node->directives, ' '), ' ')-                            . $node->selectionSet;-                    },--                    NodeKind::INT => static function (IntValueNode $node) {-                        return $node->value;-                    },--                    NodeKind::FLOAT => static function (FloatValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::STRING => function (StringValueNode $node, $key) {-                        if ($node->block) {-                            return $this->printBlockString($node->value, $key === 'description');-                        }--                        return json_encode($node->value);-                    },--                    NodeKind::BOOLEAN => static function (BooleanValueNode $node) {-                        return $node->value ? 'true' : 'false';-                    },--                    NodeKind::NULL => static function (NullValueNode $node) : string {-                        return 'null';-                    },--                    NodeKind::ENUM => static function (EnumValueNode $node) : string {-                        return $node->value;-                    },--                    NodeKind::LST => function (ListValueNode $node) : string {-                        return '[' . $this->join($node->values, ', ') . ']';-                    },--                    NodeKind::OBJECT => function (ObjectValueNode $node) : string {-                        return '{' . $this->join($node->fields, ', ') . '}';-                    },--                    NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) : string {-                        return $node->name . ': ' . $node->value;-                    },--                    NodeKind::DIRECTIVE => function (DirectiveNode $node) : string {-                        return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');-                    },--                    NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {-                        return $node->name;-                    },--                    NodeKind::LIST_TYPE => static function (ListTypeNode $node) : string {-                        return '[' . $node->type . ']';-                    },--                    NodeKind::NON_NULL_TYPE => static function (NonNullTypeNode $node) : string {-                        return $node->type . '!';-                    },--                    NodeKind::SCHEMA_DEFINITION => function (SchemaDefinitionNode $def) {-                        return $this->join(-                            [-                                'schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OPERATION_TYPE_DEFINITION => static function (OperationTypeDefinitionNode $def) : string {-                        return $def->operation . ': ' . $def->type;-                    },--                    NodeKind::SCALAR_TYPE_DEFINITION => $this->addDescription(function (ScalarTypeDefinitionNode $def) {-                        return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::OBJECT_TYPE_DEFINITION => $this->addDescription(function (ObjectTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::FIELD_DEFINITION => $this->addDescription(function (FieldDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });--                        return $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n)"))-                            . ': ' . $def->type-                            . $this->wrap(' ', $this->join($def->directives, ' '));-                    }),--                    NodeKind::INPUT_VALUE_DEFINITION => $this->addDescription(function (InputValueDefinitionNode $def) {-                        return $this->join(-                            [-                                $def->name . ': ' . $def->type,-                                $this->wrap('= ', $def->defaultValue),-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::INTERFACE_TYPE_DEFINITION => $this->addDescription(-                        function (InterfaceTypeDefinitionNode $def) {-                            return $this->join(-                                [-                                    'interface',-                                    $def->name,-                                    $this->join($def->directives, ' '),-                                    $this->block($def->fields),-                                ],-                                ' '-                            );-                        }-                    ),--                    NodeKind::UNION_TYPE_DEFINITION => $this->addDescription(function (UnionTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_TYPE_DEFINITION => $this->addDescription(function (EnumTypeDefinitionNode $def) {-                        return $this->join(-                            [-                                'enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::ENUM_VALUE_DEFINITION => $this->addDescription(function (EnumValueDefinitionNode $def) {-                        return $this->join([$def->name, $this->join($def->directives, ' ')], ' ');-                    }),--                    NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $this->addDescription(function (-                        InputObjectTypeDefinitionNode $def-                    ) {-                        return $this->join(-                            [-                                'input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    }),--                    NodeKind::SCHEMA_EXTENSION => function (SchemaTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend schema',-                                $this->join($def->directives, ' '),-                                $this->block($def->operationTypes),-                            ],-                            ' '-                        );-                    },--                    NodeKind::SCALAR_TYPE_EXTENSION => function (ScalarTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend scalar',-                                $def->name,-                                $this->join($def->directives, ' '),-                            ],-                            ' '-                        );-                    },--                    NodeKind::OBJECT_TYPE_EXTENSION => function (ObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend type',-                                $def->name,-                                $this->wrap('implements ', $this->join($def->interfaces, ' & ')),-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },--                    NodeKind::INTERFACE_TYPE_EXTENSION => function (InterfaceTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend interface',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+        return $this->p($node);+    } -                    NodeKind::UNION_TYPE_EXTENSION => function (UnionTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend union',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $def->types-                                    ? '= ' . $this->join($def->types, ' | ')-                                    : '',-                            ],-                            ' '-                        );-                    },+    /**+     * @return array<Node>+     */+    protected function listToArray(?NodeList $list) : array+    {+        return isset($list) ? iterator_to_array($list) : [];+    } -                    NodeKind::ENUM_TYPE_EXTENSION => function (EnumTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend enum',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->values),-                            ],-                            ' '-                        );-                    },+    protected function printList(?NodeList $list, $separator = '') : string+    {+        return $this->printArray($this->listToArray($list), $separator);+    } -                    NodeKind::INPUT_OBJECT_TYPE_EXTENSION => function (InputObjectTypeExtensionNode $def) {-                        return $this->join(-                            [-                                'extend input',-                                $def->name,-                                $this->join($def->directives, ' '),-                                $this->block($def->fields),-                            ],-                            ' '-                        );-                    },+    protected function printListBlock(?NodeList $list) : string+    {+        return $this->block(array_map(function ($item) : string {+            return $this->p($item);+        }, $this->listToArray($list)));+    } -                    NodeKind::DIRECTIVE_DEFINITION => $this->addDescription(function (DirectiveDefinitionNode $def) {-                        $noIndent = Utils::every($def->arguments, static function (string $arg) : bool {-                            return strpos($arg, "\n") === false;-                        });+    /**+     * @param array<Node> $list+     */+    protected function printArray(array $list, string $separator = '') : string+    {+        return $this->join(array_map(function ($item) : string {+            return $this->p($item);+        }, $list), $separator);+    } -                        return 'directive @'-                            . $def->name-                            . ($noIndent-                                ? $this->wrap('(', $this->join($def->arguments, ', '), ')')-                                : $this->wrap("(\n", $this->indent($this->join($def->arguments, "\n")), "\n"))-                            . ($def->repeatable ? ' repeatable' : '')-                            . ' on ' . $this->join($def->locations, ' | ');-                    }),-                ],-            ]-        );+    public function p(?Node $node, bool $isDescription = false) : string
    public function print(?Node $node, bool $isDescription = false) : string
shmax

comment created time in 3 days

pull request commentwebonyx/graphql-php

Fix namenode type

  1. It will make maintenance much harder (can't port changes from graphql-js as easy as we do now)

The mechanics of how the printer works have been drastically changed, sure. But the overall problem shape as well as the details for individual nodes still match quite well.

  1. Printer (and visitor in general) is implemented this way exactly to avoid recursion

There is a natural limit to the recursion depth in GraphQL schemas, so that part should be fine. It might be interesting to figure out at what point nested queries would become problematic, but I don't see us hitting a limit there realistically.

I think it is worth it for us to take advantage of PHP's type system as much as possible. While it may not be the most convenient from a maintenance perspective, considering the drift from graphql-js, it certainly makes this library better for users. I rely heavily on static analysis in my projects. It is crucial that the libraries i depend on have accurate type definitions in order for it to work well. @shmax, @simPod and myself are certainly dedicated to it and willing to put in the work.

shmax

comment created time in 3 days

Pull request review commentwebonyx/graphql-php

Fix namenode type

     "lint" : "phpcs",     "fix" : "phpcbf",     "stan": "phpstan analyse --ansi --memory-limit 2048M",-    "phpstan-baseline": "phpstan analyse --ansi --generate-baseline",+    "baseline": "phpstan analyse --ansi --generate-baseline",

:pray: Shortcuts should be short. Totally agree with the change

shmax

comment created time in 3 days

push eventnuwave/lighthouse

spawnia

commit sha 4a720310dd2f2b671975d9389285c34fc169362d

Cleanup

view details

push time in 4 days

push eventnuwave/lighthouse

spawnia

commit sha 5906fe551c9e74f5ca4e73e33efd0f7b08c7a33a

Fix

view details

push time in 4 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 95bc697d4e000a705923fa285d961bc253332467

Separate testsuite for slow console tests (#1463)

view details

spawnia

commit sha 67628a093f02de19c874ea30e2c700c271aa2db0

Merge branch 'master' into replace-partial-parser

view details

push time in 4 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 95bc697d4e000a705923fa285d961bc253332467

Separate testsuite for slow console tests (#1463)

view details

push time in 4 days

delete branch nuwave/lighthouse

delete branch : testsuite-console

delete time in 4 days

push eventnuwave/lighthouse

spawnia

commit sha 3fcb7cccaa9d133404cc9cec78c39d211b1414af

Rename usages

view details

push time in 4 days

PR opened nuwave/lighthouse

Separate testsuite for slow console tests
+9 -6

0 comment

6 changed files

pr created time in 4 days

create barnchnuwave/lighthouse

branch : testsuite-console

created branch time in 4 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 5b4022b04340e63fc1b2adc57590dfd2a18281e2

Stricter type definitions (#1426)

view details

Benedikt Franke

commit sha 2490e80e7f61c27eab043a44ed06432440ff85c7

Use larastan 0.6 (#1427)

view details

Benedikt Franke

commit sha eafd6819d594487243ae57ccd16fd54aa48b24b4

Use phpbench 0.17 (#1428)

view details

Wouter van den Brink

commit sha 9679c320001e11fac70ba79681c6ee2e1ab1949d

Extend directive command to allow choosing interfaces (#1251)

view details

Benedikt Franke

commit sha 8aae606722c2c53ced614f92dd6f6be045c7fe9d

Rework DirectiveCommand (#1429)

view details

Benedikt Franke

commit sha 4eacbe18a88cf88fd574104838fc9dc8e3cf96db

Phpstan level 8 (#1394)

view details

Benedikt Franke

commit sha 6af1e380ea7e5214c46628058f74ad282fdf6f90

Add hint to visit `/graphql-playground` after installing mll-lab/laravel-graphql-playground Thanks @AlexeiaW Closes https://github.com/nuwave/lighthouse/pull/1432

view details

Ruslan

commit sha d70fb05f3528cb45e74e9bc6595915f25627e2a9

Additional information to run the IDE helper (#1433)

view details

Benedikt Franke

commit sha 50a6b714c40766ac308dc7e25d5b64291963ce3f

Add hint that lighthouse:ide-helper requires haydenpierce/class-finder to all docs versions

view details

Benedikt Franke

commit sha e80189830d4ceaf2d7c2d77b5749d7fbf91caee0

Document clearly that `@can` uses primary keys in `find` (#1437)

view details

Benedikt Franke

commit sha bd6fe94010ec39163fde169890aec3e00cf02933

Simplify field generator (#1434)

view details

wolfiton

commit sha 194ba12118e2c3ea46e7e13bf618980cfe553bfa

Defer apollo link update (#1442)

view details

Benedikt Franke

commit sha 0afa8633124bf151a76935e5e58b4e4e7157a179

Document that `@orderBy` will use `column` arg for inputs (#1444)

view details

Benedikt Franke

commit sha 7632c8b65deff3c5bd2fb416b06f9f308add660b

Document the lifecycle of an incoming GraphQL request (#1139)

view details

Benedikt Franke

commit sha 02f97d8c428835f4caf06777536eaa78873b9505

Fix batched paginated relation queries (#1447)

view details

Thiery Laverdure

commit sha 9d5222347eef6b3575b9f3ba0984156a222e8e2e

Add cache store option to config (#1446)

view details

Benedikt Franke

commit sha 35b852063d1368d479ff14198067e1fa7cef17a7

Release v4.15.0

view details

Andrew McLagan

commit sha 6a8b526bb52d84617aa34a6b3b3cfbeaefbd089e

Add user (#1453)

view details

Ruslan

commit sha 5807d531e09316f31c8283caeaf85460d02def7b

Add missing syntax highlighting in docs (#1455)

view details

Benedikt Franke

commit sha 1b8169dd51c5042cc338007bc15e86e219eb3e8b

Fix more missing syntax highlighting in docs Thanks @ruslan

view details

push time in 4 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 5b4022b04340e63fc1b2adc57590dfd2a18281e2

Stricter type definitions (#1426)

view details

Benedikt Franke

commit sha 2490e80e7f61c27eab043a44ed06432440ff85c7

Use larastan 0.6 (#1427)

view details

Benedikt Franke

commit sha eafd6819d594487243ae57ccd16fd54aa48b24b4

Use phpbench 0.17 (#1428)

view details

Wouter van den Brink

commit sha 9679c320001e11fac70ba79681c6ee2e1ab1949d

Extend directive command to allow choosing interfaces (#1251)

view details

Benedikt Franke

commit sha 8aae606722c2c53ced614f92dd6f6be045c7fe9d

Rework DirectiveCommand (#1429)

view details

Benedikt Franke

commit sha 4eacbe18a88cf88fd574104838fc9dc8e3cf96db

Phpstan level 8 (#1394)

view details

Benedikt Franke

commit sha 6af1e380ea7e5214c46628058f74ad282fdf6f90

Add hint to visit `/graphql-playground` after installing mll-lab/laravel-graphql-playground Thanks @AlexeiaW Closes https://github.com/nuwave/lighthouse/pull/1432

view details

Ruslan

commit sha d70fb05f3528cb45e74e9bc6595915f25627e2a9

Additional information to run the IDE helper (#1433)

view details

Benedikt Franke

commit sha 50a6b714c40766ac308dc7e25d5b64291963ce3f

Add hint that lighthouse:ide-helper requires haydenpierce/class-finder to all docs versions

view details

Benedikt Franke

commit sha e80189830d4ceaf2d7c2d77b5749d7fbf91caee0

Document clearly that `@can` uses primary keys in `find` (#1437)

view details

Benedikt Franke

commit sha bd6fe94010ec39163fde169890aec3e00cf02933

Simplify field generator (#1434)

view details

wolfiton

commit sha 194ba12118e2c3ea46e7e13bf618980cfe553bfa

Defer apollo link update (#1442)

view details

Benedikt Franke

commit sha 0afa8633124bf151a76935e5e58b4e4e7157a179

Document that `@orderBy` will use `column` arg for inputs (#1444)

view details

Benedikt Franke

commit sha 7632c8b65deff3c5bd2fb416b06f9f308add660b

Document the lifecycle of an incoming GraphQL request (#1139)

view details

Benedikt Franke

commit sha 02f97d8c428835f4caf06777536eaa78873b9505

Fix batched paginated relation queries (#1447)

view details

Thiery Laverdure

commit sha 9d5222347eef6b3575b9f3ba0984156a222e8e2e

Add cache store option to config (#1446)

view details

Benedikt Franke

commit sha 35b852063d1368d479ff14198067e1fa7cef17a7

Release v4.15.0

view details

Andrew McLagan

commit sha 6a8b526bb52d84617aa34a6b3b3cfbeaefbd089e

Add user (#1453)

view details

Ruslan

commit sha 5807d531e09316f31c8283caeaf85460d02def7b

Add missing syntax highlighting in docs (#1455)

view details

Benedikt Franke

commit sha 1b8169dd51c5042cc338007bc15e86e219eb3e8b

Fix more missing syntax highlighting in docs Thanks @ruslan

view details

push time in 4 days

push eventspawnia/graphql-php

spawnia

commit sha 20325d7eae70f148879794ec30a6e0646b0b209e

Fix codestyle

view details

push time in 4 days

pull request commentwebonyx/graphql-php

Fix namenode type

@shmax The happenings in the Printer are a bit confusing. Basically, it does a bottom-up traversal of the AST where it converts all Nodes to string. One of the first things to get converted are NameNode's, since they are leaves of the AST.

shmax

comment created time in 4 days

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 class NamedTypeNode extends Node implements TypeNode     /** @var string */     public $kind = NodeKind::NAMED_TYPE; -    /** @var NameNode|string */+    /** @var NameNode */

The only time where it is a string is within Printer. As a user of this library, it is always a NameNode.

I think we do not need to complicate usage because we misuse this class in a single part of the library.

spawnia

comment created time in 4 days

push eventspawnia/graphql-php

spawnia

commit sha 58fa3722284d3764b60c30ae0c6d78f278ea18cc

Replace phpstan-ignore with assert

view details

push time in 4 days

push eventspawnia/graphql-php

spawnia

commit sha 436ee9705be17abec6ea01b88602c30df998014b

Update PHPStan

view details

spawnia

commit sha 1e74ff8a11fa5d9ef165d3844e703a13381a6d84

fix newline

view details

spawnia

commit sha 59d89d97a2337a5ad41865559ad5f8a138867b99

style

view details

spawnia

commit sha 1b22311e3c25d1528303b3f1ce7be0aa3d5c3b9e

Merge branch 'update-phpstan' into partial-parse-const-variants

view details

push time in 6 days

push eventwebonyx/graphql-php

spawnia

commit sha 1e74ff8a11fa5d9ef165d3844e703a13381a6d84

fix newline

view details

spawnia

commit sha 59d89d97a2337a5ad41865559ad5f8a138867b99

style

view details

push time in 6 days

PR opened webonyx/graphql-php

Update PHPStan
+10 -6

0 comment

6 changed files

pr created time in 6 days

create barnchwebonyx/graphql-php

branch : update-phpstan

created branch time in 6 days

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        // @phpstan-ignore-next-line the printer works bottom up, so this is already a string here

There is nothing external that might mess this up, we are not calling user code in the process of schema printing. It is just that the AST is manipulated in ways that are unusual and cause it to deviate from its usually well-typed form.

That modification is contained solely within this class and is also completely deterministic, so I think an assert() is out of place.

spawnia

comment created time in 6 days

delete branch webonyx/graphql-php

delete branch : unprivatize-schema-printer

delete time in 6 days

push eventnuwave/lighthouse

Benedikt Franke

commit sha 82da30b630e60493ee44cc46a3bca3a1cd5b678d

Fix tests, move slow console tests

view details

Benedikt Franke

commit sha c5ed2daba46348e5238a905b3bc9aff6efe53ad6

Fix some stan errors

view details

push time in 7 days

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        // @phpstan-ignore-next-line the printer works bottom up, so this is already a string here

I see, guess i will attempt an upgrade then.

spawnia

comment created time in 7 days

issue commentnuwave/lighthouse

Bug using enum type as column in @whereConditions

I understand what you are trying to do and it would be nice if the definition in type User somehow carried over to the used input, but that would involve a lot of guesswork. Lighthouse can not magically know that you meant to pass instances of your Enum. All it sees is that value can be any type, and you passed a bunch of strings.

The type of the value argument can be anything in the general case. Polymorphic inputs are not really possible in GraphQL. "a fix" would involve solving that first. If you are interested, you can dive right in to the RFC, going on for a few years now, meant to add input unions: https://github.com/graphql/graphql-spec/blob/master/rfcs/InputUnion.md

Conceptually, it might be possible to make the type of value dependent on the value of column. Such ideas have been forming in research languages such as Agda, it's called dependent typing. Fascinating subject, but GraphQL and PHP are lightyears away from it.

So, a fully type safe solution is not really possible with pure GraphQL semantics. Next best thing would be to have runtime checks. I don't quite see how we could generalize that, i would wager there are a lot of tricky edge cases and pitfalls of complexity to solve. A good starting point might be to handwrite a bunch of handlers for such inputs and look for commonalitities.

If you want to stay typesafe, you can go with a simple @eq.

faiverson

comment created time in 7 days

Pull request review commentwebonyx/graphql-php

NamedTypeNode::$name is generally a NameNode

 public function printAST($ast)                     },                      NodeKind::NAMED_TYPE => static function (NamedTypeNode $node) : string {+                        // @phpstan-ignore-next-line the printer works bottom up, so this is already a string here

Why does PHPStan not respect that ignore?

spawnia

comment created time in 7 days

push eventspawnia/graphql-php

Benedikt Franke

commit sha 0b4e2d704496ed846f052dade67c03ef30927170

Fix printer

view details

push time in 7 days

PR opened webonyx/graphql-php

Ensure NamedTypeNode::$name is always a NameNode

It is easier to deal with it if the value is known to always be the same type.

+8 -6

0 comment

3 changed files

pr created time in 7 days

create barnchspawnia/graphql-php

branch : monomorphize-named-type-node-name

created branch time in 7 days

push eventspawnia/graphql-php

Benedikt Franke

commit sha 7b97ba5e58b1b42b9f6d204d133cb9d28d95d0fe

Fix typo

view details

push time in 7 days

push eventspawnia/graphql-php

Benedikt Franke

commit sha e3d4f8c29ab34b405f7e5e0152bc5df21b224302

cs

view details

push time in 7 days

push eventspawnia/graphql-php

Max Loeb

commit sha 2b2994fdb42b7c8932865a21e86813c3beaf3568

fix: skip node correctly in KnownArgumentNamesOnDirectives rule (#686) * check for false node in visit * paarm -> param * add use skipNode * remove dead code, stanning, linting * review comment * revert changes to visitor

view details

Vladimir Razuvaev

commit sha c36914e9547ebabb16f3cf9dd9fdaa5b62dd7331

v14.0.1

view details

Benedikt Franke

commit sha f5e8d85e1229a20dbfecf87e4d92bcfd07995409

Merge branch 'master' into partial-parse-const-variants

view details

push time in 7 days

Pull request review commentwebonyx/graphql-php

Add partial parse functions for const variants

 public static function __callStatic(string $name, array $arguments) : Node     {         $parser = new Parser(...$arguments);         $parser->expect(Token::SOF);-        $type = $parser->{'parse' . $name}();++        if (in_array(+            $name,+            [+                'arguments',+                'valueLiteral',+                'array',+                'object',+                'objectField',+                'directives',+                'directive',+            ],+            true+        )) {+            $type = $parser->{'parse' . $name}(false);+        } elseif ($name === 'constArguments') {

I guess converting to actual methods will be a much bigger performance boost than anything we could do in a magic function.

spawnia

comment created time in 7 days

pull request commentnuwave/lighthouse

docs: clarify usage with laravel sanctum, login / logout mutations

@dlindenkreuz i will try out the suggested changes in https://github.com/nuwave/lighthouse-example and review once i find the time.

dlindenkreuz

comment created time in 7 days

issue commentnuwave/lighthouse

Unexpected variables input on multipart-form request

Yeah, why not.

we could check the $request->pathinfo equals /graphql

That path is configurable, so we will have to take the config into account at least. It seems like there should be a more idiomatic way, maybe we can utilize the fact that the GraphQLController will be called?

lorado

comment created time in 7 days

issue commentnuwave/lighthouse

Unexpected variables input on multipart-form request

@lorado I don't like it, but it seems like our best option. The convencience features of Laravel really bite back sometimes, it is like we are fighting the framework to not get in our way.

lorado

comment created time in 7 days

issue commentnuwave/lighthouse

@withCount returning Data instead of count

Probably related to https://github.com/nuwave/lighthouse/pull/1390

A PR with a failing test case in https://github.com/nuwave/lighthouse/blob/master/tests/Integration/Schema/Directives/CountDirectiveDBTest.php should be a great start for a fix.

pkatuwal

comment created time in 7 days

Pull request review commentwebonyx/graphql-php

Add partial parse functions for const variants

 public static function __callStatic(string $name, array $arguments) : Node     {         $parser = new Parser(...$arguments);         $parser->expect(Token::SOF);-        $type = $parser->{'parse' . $name}();++        if (in_array(+            $name,+            [+                'arguments',+                'valueLiteral',+                'array',+                'object',+                'objectField',+                'directives',+                'directive',+            ],+            true+        )) {+            $type = $parser->{'parse' . $name}(false);+        } elseif ($name === 'constArguments') {

Is this critical code?

Not at all, it's backs a bunch of obscure convenience functions for some users that manipulate schemas on the SDL level.

I wonder if it might be more performant to use a map...

Changed to use a switch, fits better and should be optimal in terms of performance.

spawnia

comment created time in 7 days

more