Introspection queries
Introspection queries allow you to return information about the schema. For example, you might want a list of GraphQL queries or details about a specific data type. The GraphQL specification determines the structure of introspection queries. See Introspection for more information.
An introspection query returns the same result whether or not you assign it an operation name, such as IntrospectionQuery
.
Disable introspection querying
Introspection querying is enabled by default. To disable it in production mode to improve security, add the following to your app/etc/env.php
file.
Copied to your clipboard'graphql' => ['disable_introspection' => true,]
Example introspection queries
Return a list of queries
The following query returns a list of queries.
Request:
Copied to your clipboardquery IntrospectionQuery {__schema {queryType {fields {namedescriptiontype{namekind}}}}}
Return a list of mutations
The following query returns a list of mutations.
Request:
Copied to your clipboardquery IntrospectionQuery {__schema {mutationType {fields {namedescriptiontype{namekind}}}}}
Get details about a data type
The following introspection query returns details about the ProductAttributeFilterInput
data type.
Request:
Copied to your clipboardquery IntrospectionQuery {__type(name: "ProductAttributeFilterInput") {namekinddescriptioninputFields {namedescriptiondefaultValue}fields {nameargs {namedescriptiontype {kindname}}type {kindname}}}}
Response:
Copied to your clipboard{"data": {"__type": {"name": "ProductAttributeFilterInput","kind": "INPUT_OBJECT","description": "ProductAttributeFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.","inputFields": [{"name": "category_id","description": "Filter product by category id","defaultValue": null},{"name": "description","description": "Attribute label: Description","defaultValue": null},{"name": "name","description": "Attribute label: Product Name","defaultValue": null},{"name": "price","description": "Attribute label: Price","defaultValue": null},{"name": "short_description","description": "Attribute label: Short Description","defaultValue": null},{"name": "sku","description": "Attribute label: SKU","defaultValue": null},{"name": "url_key","description": "The part of the URL that identifies the product","defaultValue": null}],"fields": null}}}