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/type-system/schema.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,23 @@ directives | `Directive[]` | A full list of [directives](directives.md) support
91
91
types | `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.
92
92
typeLoader | `callable` | **function($name)** Expected to return type instance given the name. Must always return the same instance if called multiple times. See section below on lazy type loading.
93
93
94
+
# Using config class
95
+
If you prefer fluid interface for config with auto-completion in IDE and static time validation,
96
+
use [`GraphQL\Type\SchemaConfig`](../reference.md#graphqltypeschemaconfig) instead of an array:
97
+
98
+
```php
99
+
<?php
100
+
use GraphQL\Type\SchemaConfig;
101
+
use GraphQL\Type\Schema;
102
+
103
+
$config = SchemaConfig::create()
104
+
->setQuery($myQueryType)
105
+
->setTypeLoader($myTypeLoader);
106
+
107
+
$schema = new Schema($config);
108
+
```
109
+
110
+
94
111
# Lazy loading of types
95
112
By default, the schema will scan all of your type, field and argument definitions to serve GraphQL queries.
96
113
It may cause performance overhead when there are many types in the schema.
0 commit comments