From 24ca17053d5863f3cf68382e099f95e594b6eb49 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Thu, 28 Jan 2021 11:10:18 +1300 Subject: [PATCH] Docs for GraphQL 4 changes --- .../19_GraphQL/07_tips_and_tricks.md | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/docs/en/02_Developer_Guides/19_GraphQL/07_tips_and_tricks.md b/docs/en/02_Developer_Guides/19_GraphQL/07_tips_and_tricks.md index ef11b24dc..8ef6f6517 100644 --- a/docs/en/02_Developer_Guides/19_GraphQL/07_tips_and_tricks.md +++ b/docs/en/02_Developer_Guides/19_GraphQL/07_tips_and_tricks.md @@ -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); -```