Custom schemas
Last updated
Was this helpful?
Last updated
Was this helpful?
The best way to start making a new schema is to take the test schema provided by the GraphQL module in src/Plugin/GraphQL/Schema/SdlSchemaTest.php
and add it to a custom module of your own. By doing this you can then start adapting the schema to your needs including your own Content types and making them available in the schema.
The code with all the demo queries and mutations in these docs can be found in .
Head to the graphql module folder and copy src/Plugin/GraphQL/Schema/SdlSchemaTest.php
to your own module which we will call mydrupalgql
. First make sure you have a .info file inside the module to make sure drupal will know about this module (for more info see ) Inside modules/mydrupalgql
create a similar file for your custom schema src/Plugin/GraphQL/Schema/SdlSchemaMyDrupalGql.php
. Make sure to adapt the namespaces on the top of the file, in the end should look something like this (some parts of the schema are marked with ...
for simplicity here. Just copy the whole thing in your own module):
Go again to the server page in /admin/config/graphql
to create a new server now for the newly created schema. When creating the server choose the "My Drupal Graphql schema" as the schema. After saving click "Explorer" and this should take you to the "Graphiql" page, but now already for you own custom schema.