How to disable the graphql introspection in Magento 2.
As we know graphql introspection querying is enabled by default and most of the time, we wish to disable graphql introspection in production mode for security reasons. And in this article, we'll show you how to stop graphql introspection using the simplest method possible.
To disable the graphql introspection it in production mode to improve security, add the following to your
'graphql' => [ 'disable_introspection' => true, ]
We need to perform the following commands now that we've updated the env file.
php bin/magento s:up php bin/magento s:s:d -f php bin/magento setup:di:compile php bin/magento c:c
All set, now use your graphql endpoint to connect to graphql. By default, it looks like this. As you can see, the graphql introspection query is no longer functional.
If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.
I hope this article helps you to find what you were looking for.
Bookmark it for your future reference. Do comment below if you have any other questions on that.
P.S. Do share this article with your team.
Review other articles maybe it'll help you too.
- How to Create Custom GraphQL in Magento 2
- List of GraphQL Queries and Mutations for Magento 2
- How to Add Image Uploader on Store Configuration in Magento 2
- How to Add Custom Select/MultiSelect Options on Store Configuration in Magento 2
- How to Add Dynamic Row on Store Configuration in Magento 2
- How to Add Date & time Picker on Store Configuration in Magento 2
- How to Add Custom Validation Rule in Magento 2
- How to Setup Magento 2 PWA Studio
- How to Get Current Product
- Get Product Collection with Filters