Skip to content

Conversation

mcg-web
Copy link
Contributor

@mcg-web mcg-web commented Feb 7, 2018

Q A
Bug fix? yes/no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Documented? yes
Fixed tickets none
License MIT

Explicitly declare non detected types

Before 0.11 all types was declare as non detected types, this was not the correct way of declaring types.
This could lead to some performances issues or/and wrong types public exposition (in introspection query).
See webonyx/graphql-php documentations for more details

Since 0.11 Non detect types should be explicitly declare

here a concrete example:

Query:
   type: object
   config:
      fields:
         foo: {type: FooInterface!}

FooInterface:
   type: interface
   config:
      fields:
         id: {type: ID!}
      resolveType: '@=resolver("foo", [value])'

Bar:
   type: object
   config:
      fields:
         id: {type: ID!}
         # ...
      interfaces: [FooInterface]

Baz:
   type: object
   config:
      fields:
         id: {type: ID!}
         # ...
      interfaces: [FooInterface]

In above example Baz an Bar can not be detected by graphql-php during static schema analysis,
an GraphQL\Error\InvariantViolation exception will be throw with the following message:

Could not find possible implementing types for FooInterface in schema.
Check that schema.types is defined and is an array of all possible types in the schema.

here how this can be fix:

overblog_graphql:
   definitions:
      schema:
         query: Query
         types: [Bar, Baz]

@mcg-web mcg-web merged commit 4720e0c into overblog:master Feb 7, 2018
@mcg-web mcg-web deleted the explicitly-declare-non-detected-types branch February 7, 2018 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants