You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stop calling typeLoader for built-in scalar names (#1884)
Calling the typeLoader for built-in scalar names (String, Int, Float,
Boolean, ID) breaks downstream consumers whose typeLoaders were not
designed to handle these names.
Remove typeLoader-based scalar override support, keeping only
types-based overrides. Guard loadType() so the typeLoader is never
invoked for built-in scalar names.
Fixes#1874
| query |`ObjectType` or `callable(): ?ObjectType` or `null`|**Required.** Object type (usually named `Query`) containing root-level fields of your read API |
84
-
| mutation |`ObjectType` or `callable(): ?ObjectType` or `null`| Object type (usually named `Mutation`) containing root-level fields of your write API |
85
-
| subscription |`ObjectType` or `callable(): ?ObjectType` or `null`| Reserved for future subscriptions implementation. Currently presented for compatibility with introspection query of **graphql-js**, used by various clients (like Relay or GraphiQL) |
86
-
| directives |`array<Directive>`| A full list of [directives](type-definitions/directives.md) supported by your schema. By default, contains built-in **@skip** and **@include** directives.<br><br> If you pass your own directives and still want to use built-in directives - add them explicitly. For example:<br><br> _array_merge(GraphQL::getStandardDirectives(), [$myCustomDirective]);_|
87
-
| types |`array<ObjectType>`| List of object types which cannot be detected by **graphql-php** during static schema analysis.<br><br>Most often this happens when the object type is never referenced in fields directly but is still a part of a schema because it implements an interface which resolves to this object type in its **resolveType** callable. <br><br> Note that you are not required to pass all of your types here - it is simply a workaround for a concrete use-case. |
88
-
| typeLoader |`callable(string $name): Type`| Expected to return a type instance given the name. Must always return the same instance if called multiple times, see [lazy loading](#lazy-loading-of-types). See section below on lazy type loading. |
| query |`ObjectType` or `callable(): ?ObjectType` or `null`|**Required.** Object type (usually named `Query`) containing root-level fields of your read API |
84
+
| mutation |`ObjectType` or `callable(): ?ObjectType` or `null`| Object type (usually named `Mutation`) containing root-level fields of your write API |
85
+
| subscription |`ObjectType` or `callable(): ?ObjectType` or `null`| Reserved for future subscriptions implementation. Currently presented for compatibility with introspection query of **graphql-js**, used by various clients (like Relay or GraphiQL) |
86
+
| directives |`array<Directive>`| A full list of [directives](type-definitions/directives.md) supported by your schema. By default, contains built-in **@skip** and **@include** directives.<br><br> If you pass your own directives and still want to use built-in directives - add them explicitly. For example:<br><br> _array_merge(GraphQL::getStandardDirectives(), [$myCustomDirective]);_|
87
+
| types |`iterable<Type&NamedType>`| Additional types to register in the schema.<br><br>Use this for object types that are not directly referenced in fields but implement an interface that resolves to them via **resolveType**.<br><br>Can also contain custom scalar types named like built-in scalars (`String`, `Int`, etc.) to [override them](type-definitions/scalars.md#overriding-built-in-scalars) on a per-schema basis. |
88
+
| typeLoader |`callable(string $name): Type`| Expected to return a type instance given the name. Must always return the same instance if called multiple times, see [lazy loading](#lazy-loading-of-types). See section below on lazy type loading. |
Copy file name to clipboardExpand all lines: docs/type-definitions/scalars.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,3 +106,30 @@ $emailType = new CustomScalarType([
106
106
107
107
Keep in mind the passed functions will be called statically, so a passed in `callable`
108
108
such as `[Foo::class, 'bar']` should only reference static class methods.
109
+
110
+
## Overriding Built-in Scalars
111
+
112
+
You can override built-in scalars (`String`, `Int`, `Float`, `Boolean`, `ID`) on a per-schema basis by passing a custom scalar with the same name through the `types` option.
0 commit comments