I am using Node.js & GraphQL to build an API server.
I was wondering how I can enable the feature that the schema will show automatically when using tools like Postman/GraphQL Playground to send requests to remote API endpoints(currently using heroku).
When I launch the server and GraphQL Playground on localhost, it will show the schema and docs on the right side like below.
But when I change the endpoint to remote server (heroku in this case), it won't show any schema or docs. The schema and docs sidebar just keeps loading like the picture below (I hide the url for privacy issue)
Also not showing in Postman
Do I need to configure something or use some package in my server so that it will return and show the schema automatically on client-side?
Thank you.
You might try either set
introspection: true
flag in the constructor parameters of your apollo-server or, if it is suitable for your needs, to deploy onto heroku the development version of your app.An explanation:
To see the schema and docs, your client should obviously fetch it first. This request for graphQL schema usually called an "introspection".
Having the full schema of backend graphQL API is undoubtedly convenient during the development.
However, when our app is running in the production environment, we usually should expect malicious clients. Therefore, sending introspection in the production mode might be unsafe, because it would give a lot of additional information to the potential attacker.
That's why the introspection turned off by default in the production environment for the current version of appolo-server.