{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1399,"path":"api-reference/web-services/test-gql-schema.md","title":"Test GraphQL APIs with GraphQL Explorer","bundle":null,"doc_type":null,"release":"australia","body":"\n# Test GraphQL APIs with GraphQL Explorer\n\nTest query your GraphQL APIs using an integrated GraphQL testing tool.\n\n## Before you begin\n\nCreate a schema for your GraphQL API. For more information, see [Create a GraphQL schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/build-graphql-scripted-schema.md).\n\nEnabling introspective queries allows GraphQL Explorer to show the schemas on the instance in the Documentation Explorer and as auto-complete suggestions, which makes finding queries and mutations easier. For more information, see [Enable introspective queries for GraphQL schemas](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/enable-introspective-queries-graphql-schemas.md).\n\n**Note:** Don’t use introspective queries in a production environment.\n\nRole required: graphql\\_schema\\_admin or admin\n\n## About this task\n\nThe GraphQL Explorer integrates the GraphiQL IDE into the ServiceNow AI Platform. For additional information about the interface, see the [GraphiQL readme](https://github.com/graphql/graphiql/blob/main/packages/graphiql/README.md) in the GraphiQL GitHub repository.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Web Services** &gt; **GraphQL** &gt; **GraphQL Explorer**.\n\n2.  If you enabled introspection, in the left sidebar, select the Show Documentation Explorer icon \\(\\[Omitted image \"graphql-show-doc-explorer.png\"\\] Alt text: Show Documentation Explorer icon\\) to view and search for available queries or mutations.\n\n3.  In the editor, enter a query to the schema.\n\n    Include both the application and schema namespaces in the query. For information about directives you can apply, see [Directives and global functions](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/scripted-graph-ql.md).\n\n    This example shows using both the application and schema namespaces:\n\n    -   Application namespace: `x_graph_scope`\n    -   Schema namespace: `planet`\n    ```\n    query {\n      x_graph_scope {\n        planet {\n          findAll {\n            name\n            mass\n            distance\n          }\n        }\n      }\n    }\n    ```\n\n    This example shows using the @defer directive to stream results for the openedBy field after the initial incident response.\n\n    ```\n    query findIncidents {\n      now {\n        incident {\n          findAll {\n            description {\n              displayValue\n            }\n            ...\n            @defer(label: \"my-label\", if: true) {\n              openedBy {\n                firstName\n                lastName\n              }\n            }\n          }\n        }\n      }\n    }\n    ```\n\n4.  At the bottom of the editor, select **Variables** and enter any necessary variables.\n\n5.  Select the Execute query icon \\(\\[Omitted image \"graphql-execute-query.png\"\\] Alt text: Execute query icon\\).\n\n    **Tip:** You can also use a keyboard shortcut. To see the list of available keyboard shortcuts, select the Open short keys dialog icon \\(\\[Omitted image \"graphql-keyboard-shortcuts.png\"\\] Alt text: Open short keys dialog icon\\).\n\n    The result of your query returns in the right pane.\n\n6.  Select the Add tab icon \\(\\[Omitted image \"graphql-add-tab.png\"\\] Alt text: Add tab icon\\) to run additional queries.\n\n\n## What to do next\n\nIf you need to view a list of previous queries, in left sidebar, select the Show History icon \\(\\[Omitted image \"graphql-show-history.png\"\\] Alt text: Show History icon\\).\n\nTo access record data in a component, you can create a custom component and query your scripted GraphQL schema from the component. For more information, see [Query a GraphQL schema from a component](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/query-schema-from-component.md).\n\n**Parent Topic:**[Query record data using the GraphQL API framework](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/scripted-graph-ql.md)\n\n"}}