pi88a
pi88a

Reputation: 81

Strapi v4: How to enable graphql playground in prod?

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,
    },
  },
});
```

Upvotes: 4

Views: 3415

Answers (3)

Abdullah Ayoub
Abdullah Ayoub

Reputation: 39

Just make sure playgroundAlways: true in config/plugin.js By default it is false and since I changed it to true it started working for more : https://github.com/strapi/strapi/issues/2309

Upvotes: 0

atazmin
atazmin

Reputation: 5677

This worked for me Strapi v.4 on Heroku with postgreSQL

config/plugins.js

module.exports = ({ env }) => ({        
  graphql: {
    enabled: true,
    config: {
      endpoint: "/graphql",
      shadowCRUD: true,
      playgroundAlways: true,
      defaultLimit: 10,
      maxLimit: 20,
      apolloServer: {
        tracing: true,
      },
    },
  },
});

Upvotes: 1

Alex TechNoir
Alex TechNoir

Reputation: 150

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

Upvotes: 1

Related Questions