Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__typename is not defined. Bug in 5.1 #627

Closed
edgarsn opened this issue Apr 23, 2020 · 4 comments
Closed

__typename is not defined. Bug in 5.1 #627

edgarsn opened this issue Apr 23, 2020 · 4 comments
Labels

Comments

@edgarsn
Copy link
Contributor

edgarsn commented Apr 23, 2020

Versions:

  • graphql-laravel Version: 5.1.0
  • Laravel Version: v6.18.10
  • PHP Version: 7.2.25

Description:

I upgraded from 5.0 to 5.1 and errors to all of my types are being thrown.

[2020-04-23 10:59:52] local.ERROR: Field "__typename" is not defined for type "Author" {"exception":"[object] (GraphQL\\Error\\InvariantViolation(code: 0): Field \"__typename\" is not defined for type \"Author\" at /home/vagrant/code/vendor/webonyx/graphql-php/src/Utils/Utils.php:319)
[stacktrace]
#0 /home/vagrant/code/vendor/webonyx/graphql-php/src/Type/Definition/ObjectType.php(123): GraphQL\\Utils\\Utils::invariant(false, 'Field \"__typena...', '__typename', 'Author')
#1 /home/vagrant/code/vendor/rebing/graphql-laravel/src/Support/RulesInFields.php(76): GraphQL\\Type\\Definition\\ObjectType->getField('__typename')
#2 /home/vagrant/code/vendor/rebing/graphql-laravel/src/Support/RulesInFields.php(39): Rebing\\GraphQL\\Support\\RulesInFields->getRules(Array, NULL, Object(GraphQL\\Type\\Definition\\ObjectType))
#3 /home/vagrant/code/vendor/rebing/graphql-laravel/src/Support/Field.php(102): Rebing\\GraphQL\\Support\\RulesInFields->get()
#4 /home/vagrant/code/vendor/rebing/graphql-laravel/src/Support/Field.php(151): Rebing\\GraphQL\\Support\\Field->validateFieldArguments(Array)
#5 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(632): Rebing\\GraphQL\\Support\\Field->Rebing\\GraphQL\\Support\\{closure}(NULL, Array, NULL, Object(GraphQL\\Type\\Definition\\ResolveInfo))
#6 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(560): GraphQL\\Executor\\ReferenceExecutor->resolveOrError(Object(GraphQL\\Type\\Definition\\FieldDefinition), Object(GraphQL\\Language\\AST\\FieldNode), Object(Closure), NULL, NULL, Object(GraphQL\\Type\\Definition\\ResolveInfo))
#7 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1247): GraphQL\\Executor\\ReferenceExecutor->resolveField(Object(GraphQL\\Type\\Definition\\ObjectType), NULL, Object(ArrayObject), Array)
#8 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(257): GraphQL\\Executor\\ReferenceExecutor->executeFields(Object(GraphQL\\Type\\Definition\\ObjectType), NULL, Array, Object(ArrayObject))
#9 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(208): GraphQL\\Executor\\ReferenceExecutor->executeOperation(Object(GraphQL\\Language\\AST\\OperationDefinitionNode), NULL)
#10 /home/vagrant/code/vendor/webonyx/graphql-php/src/Executor/Executor.php(155): GraphQL\\Executor\\ReferenceExecutor->doExecute()
#11 /home/vagrant/code/vendor/webonyx/graphql-php/src/GraphQL.php(165): GraphQL\\Executor\\Executor::promiseToExecute(Object(GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter), Object(GraphQL\\Type\\Schema), Object(GraphQL\\Language\\AST\\DocumentNode), NULL, NULL, Array, NULL, NULL)
#12 /home/vagrant/code/vendor/webonyx/graphql-php/src/GraphQL.php(98): GraphQL\\GraphQL::promiseToExecute(Object(GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter), Object(GraphQL\\Type\\Schema), '{\
  channels {\
...', NULL, NULL, Array, NULL, NULL, NULL)
#13 /home/vagrant/code/vendor/rebing/graphql-laravel/src/GraphQL.php(148): GraphQL\\GraphQL::executeQuery(Object(GraphQL\\Type\\Schema), '{\
  channels {\
...', NULL, NULL, Array, NULL, NULL)
#14 /home/vagrant/code/vendor/rebing/graphql-laravel/src/GraphQL.php(126): Rebing\\GraphQL\\GraphQL->queryAndReturnResult('{\
  channels {\
...', Array, Array)
#15 /home/vagrant/code/vendor/rebing/graphql-laravel/src/GraphQLController.php(73): Rebing\\GraphQL\\GraphQL->query('{\
  channels {\
...', Array, Array)
#16 /home/vagrant/code/vendor/rebing/graphql-laravel/src/GraphQLController.php(48): Rebing\\GraphQL\\GraphQLController->executeQuery('default', Array)
#17 [internal function]: Rebing\\GraphQL\\GraphQLController->query(Object(Illuminate\\Http\\Request), 'default')
#18 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#19 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('query', Array)
#20 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Rebing\\GraphQL\\GraphQLController), 'query')
#21 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#22 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\\Routing\\Route->run()
#23 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/vagrant/code/vendor/barryvdh/laravel-cors/src/HandleCors.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#28 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#29 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#30 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#31 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#32 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#33 /home/vagrant/code/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#37 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#38 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#43 /home/vagrant/code/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#44 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\\Cors\\HandlePreflight->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 /home/vagrant/code/orion/core/src/Foundation/Http/Middleware/HandlePreflight.php(33): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Orion\\Core\\Foundation\\Http\\Middleware\\HandlePreflight->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#49 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#50 /home/vagrant/code/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#51 {main}
"} 

Steps To Reproduce:

Everything works in 5.0, but after running composer update theese errors appeared. I didn't find any migration guide for this, so I didn't make any query/type changes and left as is in 5.0.

@edgarsn edgarsn added the bug label Apr 23, 2020
@mfn
Copy link
Collaborator

mfn commented Apr 23, 2020

I upgraded from 5.0 to 5.1

Since the stacktrace says this come from RulesInFields, maybe it's related to #608 , can you debug?

@mfn
Copy link
Collaborator

mfn commented Apr 23, 2020

Hah, yeah I see and know this bug; it's this code:

            $fieldObject = $parentType->getField($name);

Originally in the PR by @crissi we had this protected by an InvariantViolation catch block (I believe) and since we couldn't imagine the scenario where it happens, it was removed.

I guess now we know 😄

@mfn
Copy link
Collaborator

mfn commented Apr 23, 2020

This is pretty breaking change :-( Not sure why we didn't catch this in the tests.

Preparing a 5.1.1 hotfix now to revert this particular change, stay tuned

@mfn mfn mentioned this issue Apr 23, 2020
5 tasks
@mfn
Copy link
Collaborator

mfn commented Apr 23, 2020

Fixed with https://github.com/rebing/graphql-laravel/releases/tag/5.1.1 !

@mfn mfn closed this as completed Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants