mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Docs for GraphQL 4 changes
This commit is contained in:
parent
caa224e37b
commit
24ca17053d
@ -24,7 +24,7 @@ If you need the type name during normal execution of your app, e.g. to display i
|
||||
on the cached typenames, which are persisted alongside your generated schema code.
|
||||
|
||||
```php
|
||||
SchemaFactory::get('default')->getTypeNameForClass($className);
|
||||
SchemaFactory::singleton()->get('default')->getTypeNameForClass($className);
|
||||
```
|
||||
|
||||
## Persisting queries
|
||||
@ -145,12 +145,13 @@ This feature is experimental, and has not been thoroughly evaluated for security
|
||||
## Schema introspection
|
||||
|
||||
Some GraphQL clients such as [Apollo](http://apollographql.com) require some level of introspection
|
||||
into the schema. While introspection is [part of the GraphQL spec](http://graphql.org/learn/introspection/),
|
||||
this module provides a limited API for fetching it via non-graphql endpoints. By default, the `graphql/`
|
||||
controller provides a `types` action that will return the type schema (serialised as JSON) dynamically.
|
||||
into the schema. The `SchemaTranscriber` class will persist this data to a static file in an event
|
||||
that is fired on completion of the schema build. This file can then be consumed by a client side library
|
||||
like Apollo. The `silverstripe-admin` module is built to consume this data and expects it to be in a
|
||||
web-accessible location.
|
||||
|
||||
*GET http://example.com/graphql/types*
|
||||
```js
|
||||
|
||||
```json
|
||||
{
|
||||
"data":{
|
||||
"__schema":{
|
||||
@ -166,19 +167,3 @@ controller provides a `types` action that will return the type schema (serialise
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
As your schema grows, introspecting it dynamically may have a performance hit. Alternatively,
|
||||
if you have the `silverstripe/assets` module installed (as it is in the default SilverStripe installation),
|
||||
GraphQL can cache your schema as a flat file in the `assets/` directory. To enable this, simply
|
||||
set the `cache_types_in_filesystem` setting to `true` on `SilverStripe\GraphQL\Controller`. Once enabled,
|
||||
a `types.graphql` file will be written to your `assets/` directory on `flush`.
|
||||
|
||||
When `cache_types_in_filesystem` is enabled, it is recommended that you remove the extension that
|
||||
provides the dynamic introspection endpoint.
|
||||
|
||||
```php
|
||||
use SilverStripe\GraphQL\Controller;
|
||||
use SilverStripe\GraphQL\Extensions\IntrospectionProvider;
|
||||
|
||||
Controller::remove_extension(IntrospectionProvider::class);
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user