api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.43k stars 866 forks source link

GraphQL schema generation not working #4472

Closed lermontex closed 3 years ago

lermontex commented 3 years ago

API Platform version(s) affected: dev/main

Description

symfony console api:graphql:export > schema.graphql

[critical] Error thrown while running command "api:graphql:export". Message: "Warning: Undefined array key "type""

In FieldDefinition.php line 208:

  Warning: Undefined array key "type"

The automatic scheme for the graphql playgrounds (api/graphql/graphiql and api/graphql/graphql_playground) also does not work:

{
  "errors": [
    {
      "debugMessage": "Warning: Undefined array key \"type\"",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 8,
          "column": 9
        }
      ],
      "path": [
        "__schema",
        "types"
      ],
      "trace": [
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 213,
          "call": "GraphQL\\Type\\Definition\\FieldDefinition::getType()"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 222,
          "call": "GraphQL\\Utils\\TypeInfo::extractTypes(GraphQLType: Mutation, array(45))"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 208,
          "call": "GraphQL\\Type\\Schema::collectAllTypes()"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Type/Introspection.php",
          "line": 240,
          "call": "GraphQL\\Type\\Schema::getTypeMap()"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "GraphQL\\Type\\Introspection::GraphQL\\Type\\{closure}(instance of GraphQL\\Type\\Schema, array(0), null, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: __Schema, instance of GraphQL\\Type\\Schema, instance of ArrayObject(1), array(2))"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: __Schema, instance of GraphQL\\Type\\Schema, array(1), instance of ArrayObject(4))"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1106,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: __Schema, instance of ArrayObject(1), array(1), instance of GraphQL\\Type\\Schema)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 793,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of GraphQL\\Type\\Schema)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 741,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of GraphQL\\Type\\Schema)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of GraphQL\\Type\\Schema)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 557,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of GraphQL\\Type\\Schema)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Query, null, instance of ArrayObject(1), array(1))"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: Query, null, array(0), instance of ArrayObject(1))"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, null, array(0), 'IntrospectionQuery', null)"
        },
        {
          "file": "/srv/app/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, '\n    query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        \n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment FullType on __Type {\n      kind\n      name\n      description\n      \n      fields(includeDeprecated: true) {\n        name\n        description\n        args {\n          ...InputValue\n        }\n        type {\n          ...TypeRef\n        }\n        isDeprecated\n        deprecationReason\n      }\n      inputFields {\n        ...InputValue\n      }\n      interfaces {\n        ...TypeRef\n      }\n      enumValues(includeDeprecated: true) {\n        name\n        description\n        isDeprecated\n        deprecationReason\n      }\n      possibleTypes {\n        ...TypeRef\n      }\n    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment TypeRef on __Type {\n      kind\n      name\n      ofType {\n        kind\n        name\n        ofType {\n          kind\n          name\n          ofType {\n            kind\n            name\n            ofType {\n              kind\n              name\n              ofType {\n                kind\n                name\n                ofType {\n                  kind\n                  name\n                  ofType {\n                    kind\n                    name\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  ', null, null, array(0), 'IntrospectionQuery', null, null)"
        },
        {
          "file": "/srv/app/vendor/api-platform/core/src/GraphQl/Executor.php",
          "line": 34,
          "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '\n    query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        \n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment FullType on __Type {\n      kind\n      name\n      description\n      \n      fields(includeDeprecated: true) {\n        name\n        description\n        args {\n          ...InputValue\n        }\n        type {\n          ...TypeRef\n        }\n        isDeprecated\n        deprecationReason\n      }\n      inputFields {\n        ...InputValue\n      }\n      interfaces {\n        ...TypeRef\n      }\n      enumValues(includeDeprecated: true) {\n        name\n        description\n        isDeprecated\n        deprecationReason\n      }\n      possibleTypes {\n        ...TypeRef\n      }\n    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment TypeRef on __Type {\n      kind\n      name\n      ofType {\n        kind\n        name\n        ofType {\n          kind\n          name\n          ofType {\n            kind\n            name\n            ofType {\n              kind\n              name\n              ofType {\n                kind\n                name\n                ofType {\n                  kind\n                  name\n                  ofType {\n                    kind\n                    name\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  ', null, null, array(0), 'IntrospectionQuery', null, null)"
        },
        {
          "file": "/srv/app/vendor/api-platform/core/src/GraphQl/Action/EntrypointAction.php",
          "line": 88,
          "call": "ApiPlatform\\GraphQl\\Executor::executeQuery(instance of GraphQL\\Type\\Schema, '\n    query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        \n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment FullType on __Type {\n      kind\n      name\n      description\n      \n      fields(includeDeprecated: true) {\n        name\n        description\n        args {\n          ...InputValue\n        }\n        type {\n          ...TypeRef\n        }\n        isDeprecated\n        deprecationReason\n      }\n      inputFields {\n        ...InputValue\n      }\n      interfaces {\n        ...TypeRef\n      }\n      enumValues(includeDeprecated: true) {\n        name\n        description\n        isDeprecated\n        deprecationReason\n      }\n      possibleTypes {\n        ...TypeRef\n      }\n    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment TypeRef on __Type {\n      kind\n      name\n      ofType {\n        kind\n        name\n        ofType {\n          kind\n          name\n          ofType {\n            kind\n            name\n            ofType {\n              kind\n              name\n              ofType {\n                kind\n                name\n                ofType {\n                  kind\n                  name\n                  ofType {\n                    kind\n                    name\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  ', null, null, array(0), 'IntrospectionQuery')"
        },
        {
          "file": "/srv/app/vendor/symfony/http-kernel/HttpKernel.php",
          "line": 157,
          "call": "ApiPlatform\\GraphQl\\Action\\EntrypointAction::__invoke(instance of Symfony\\Component\\HttpFoundation\\Request)"
        },
        {
          "file": "/srv/app/vendor/symfony/http-kernel/HttpKernel.php",
          "line": 79,
          "call": "Symfony\\Component\\HttpKernel\\HttpKernel::handleRaw(instance of Symfony\\Component\\HttpFoundation\\Request, 1)"
        },
        {
          "file": "/srv/app/vendor/symfony/http-kernel/Kernel.php",
          "line": 199,
          "call": "Symfony\\Component\\HttpKernel\\HttpKernel::handle(instance of Symfony\\Component\\HttpFoundation\\Request, 1, true)"
        },
        {
          "file": "/srv/app/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php",
          "line": 37,
          "call": "Symfony\\Component\\HttpKernel\\Kernel::handle(instance of Symfony\\Component\\HttpFoundation\\Request)"
        },
        {
          "file": "/srv/app/vendor/autoload_runtime.php",
          "line": 35,
          "call": "Symfony\\Component\\Runtime\\Runner\\Symfony\\HttpKernelRunner::run()"
        },
        {
          "file": "/srv/app/public/index.php",
          "line": 5,
          "function": "require_once('/srv/app/vendor/autoload_runtime.php')"
        }
      ]
    }
  ]
}
lermontex commented 3 years ago

@alanpoulain, could this be related to the latest PRs?

alanpoulain commented 3 years ago

I don't have the issue on main. You have probably created a bad type.

lermontex commented 3 years ago

It looks like the problem is really on my side, thanks!