Skip to content

Commit a3b6974

Browse files
committed
Added entry in docs about schema config class
1 parent 90602b3 commit a3b6974

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/type-system/schema.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ directives | `Directive[]` | A full list of [directives](directives.md) support
9191
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.
9292
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.
9393

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+
94111
# Lazy loading of types
95112
By default, the schema will scan all of your type, field and argument definitions to serve GraphQL queries.
96113
It may cause performance overhead when there are many types in the schema.

0 commit comments

Comments
 (0)