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
Copy file name to clipboardExpand all lines: docs/schema-definition.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,20 +78,20 @@ Field names of Mutation type are usually verbs and they almost always have argum
78
78
with complex input values (see [Mutations and Input Types](type-definitions/inputs.md) for details).
79
79
80
80
# Configuration Options
81
-
Schema constructor expects an instance of [`GraphQL\Type\SchemaConfig`](class-reference.md#graphqltypeschemaconfig)
82
-
or an array with following options:
81
+
The schema constructor expects an instance of [`GraphQL\Type\SchemaConfig`](class-reference.md#graphqltypeschemaconfig)
82
+
or an array with the following options:
83
83
84
84
Option | Type | Notes
85
85
------------ | -------- | -----
86
86
query | `ObjectType` | **Required.** Object type (usually named "Query") containing root-level fields of your read API
87
87
mutation | `ObjectType` | Object type (usually named "Mutation") containing root-level fields of your write API
88
88
subscription | `ObjectType` | Reserved for future subscriptions implementation. Currently presented for compatibility with introspection query of **graphql-js**, used by various clients (like Relay or GraphiQL)
89
89
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]);*
90
-
types | `array<ObjectType>` | List of object types which cannot be detected by **graphql-php** during static schema analysis.<br><br>Most often it 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 concrete use-case.
91
-
typeLoader | `callable(string $name): Type` | Expected to return 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.
90
+
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 concrete a use-case.
91
+
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.
92
92
93
93
# Using config class
94
-
If you prefer fluid interface for config with auto-completion in IDE and static time validation,
94
+
If you prefer a fluid interface for the config with auto-completion in IDE and static time validation,
95
95
use [`GraphQL\Type\SchemaConfig`](class-reference.md#graphqltypeschemaconfig) instead of an array:
96
96
97
97
```php
@@ -110,10 +110,10 @@ $schema = new Schema($config);
110
110
By default, the schema will scan all of your type, field and argument definitions to serve GraphQL queries.
111
111
It may cause performance overhead when there are many types in the schema.
112
112
113
-
In this case, it is recommended to pass **typeLoader** option to schema constructor and define all
113
+
In this case, it is recommended to pass the **typeLoader** option to the schema constructor and define all
114
114
of your object **fields** as callbacks.
115
115
116
-
Type loading concept is very similar to PHP class loading, but keep in mind that **typeLoader** must
116
+
Type loading is very similar to PHP class loading, but keep in mind that the**typeLoader** must
117
117
always return the same instance of a type. A good way to ensure this is to use a type registry:
118
118
119
119
```php
@@ -160,25 +160,25 @@ $schema = new Schema([
160
160
]);
161
161
```
162
162
163
-
You can automate this registry as you wish to reduce boilerplate or even
164
-
introduce Dependency Injection Container if your types have other dependencies.
163
+
You can automate this registry if you wish to reduce boilerplate or even
164
+
introduce a Dependency Injection Container if your types have other dependencies.
165
165
166
166
Alternatively, all methods of the registry could be static - then there is no need
167
167
to pass it in the constructor - instead use **TypeRegistry::myAType()** in your type definitions.
168
168
169
169
# Schema Validation
170
170
By default, the schema is created with only shallow validation of type and field definitions
171
-
(because validation requires full schema scan and is very costly on bigger schemas).
171
+
(because validation requires a full schema scan and is very costly on bigger schemas).
172
172
173
-
There is a special method **assertValid()** on schema instance which throws
173
+
There is a special method **assertValid()** on the schema instance which throws
174
174
`GraphQL\Error\InvariantViolation` exception when it encounters any error, like:
175
175
176
176
- Invalid types used for fields/arguments
177
177
- Missing interface implementations
178
178
- Invalid interface implementations
179
179
- Other schema errors...
180
180
181
-
Schema validation is supposed to be used in CLI commands or during build step of your app.
181
+
Schema validation is supposed to be used in CLI commands or during a build step of your app.
0 commit comments