graphql-php icon indicating copy to clipboard operation
graphql-php copied to clipboard

Exclude unused standard types from the schema

Open spawnia opened this issue 4 years ago • 1 comments

The current implementation of Schema always adds standard scalar types to the schema, even if they are not used. This differs from the reference implementation, which has added quite a few test cases that rely on missing standard scalars.

We should align our behaviour with the specification, see http://spec.graphql.org/draft/#sec-Scalars.Built-in-Scalars:

If a built-in scalar type is not referenced anywhere in a schema (there is no field, argument, or input field of that type) then it must not be included.

spawnia avatar Oct 10 '21 08:10 spawnia

Aligning the behaviour of this library exactly with graphql-js is difficult due to lazy loading. Given we don't want to eagerly traverse the schema and all its types, how can we differentiate if a standard scalar is supposed to be included in the schema when calling Schema::getType('Int')?

I think we should strive to align the behaviour with graphql-js if possible, but not at the cost of totally bombing performance. Due to the share-nothing request model of PHP, lazy type loading is very important.

spawnia avatar Oct 18 '21 16:10 spawnia