Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strapi v4: How to enable graphql playground in prod?

Tags:

graphql

strapi

my-app.herokuapp.com/graphql responses with 'GET query missing.' and doesn't provide graphql playground interface.

Conf from https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#configurations doesn't work for me.

./config/plugins.js

module.exports = ({ env }) => ({
  //
  graphql: {
    config: {
      endpoint: "/graphql",
      shadowCRUD: true,
      playgroundAlways: true,
      depthLimit: 100,
      apolloServer: {
        tracing: false,
      },
    }
  },
});

and this from forums too..

module.exports = ({ env }) => ({
  //
  graphql: {
    endpoint: "/graphql",
    shadowCRUD: true,
    playgroundAlways: true,
    depthLimit: 100,
    apolloServer: {
      tracing: false,
    },
  },
});
```
like image 451
pi88a Avatar asked Oct 20 '25 02:10

pi88a


1 Answers

When I tried to query my GraphQL API on Heroku with Postman, at first it said "restricted access" or something like that. Then I realised that, unlike with MongoDB, when you deploy PostgreSQL on Heroku, the latter creates it's own database, different from the one created in dev environment

So, in prod, Strapi content-types are saved, but naturally some things are wiped, like the entries in collections and permissions settings. I had "find" and "findOne" checkboxes unchecked there, so I checked them back on. Prod API still shows "GET query missing", but the data appeared in Postman and the app worked as expected

If you have PostgreSQL deployed, check your Strapi settings (Settings -> Users & Permissions Plugin -> Roles -> Permissions -> name of your collection type) and see if the checkboxes are unchecked and try to check them back. That did the trick for me

like image 153
Alex TechNoir Avatar answered Oct 22 '25 04:10

Alex TechNoir