fix: handle graphQL: false on globals when building policy type (#3729)

This commit is contained in:
Take Weiland
2023-10-19 15:13:51 +02:00
committed by GitHub
parent 67682248c8
commit bcdd2d626f
3 changed files with 17 additions and 0 deletions

View File

@@ -217,6 +217,9 @@ export default function buildPoliciesType(payload: Payload): GraphQLObjectType {
})
Object.values(payload.config.globals).forEach((global: SanitizedGlobalConfig) => {
if (global.graphQL === false) {
return
}
const globalPolicyType = buildPolicyType({
entity: global,
type: 'global',

View File

@@ -80,6 +80,12 @@ export default buildConfigWithDefaults({
},
],
},
{
slug: 'without-graphql',
access,
graphQL: false,
fields: [],
},
],
onInit: async (payload) => {
await payload.create({

View File

@@ -224,5 +224,13 @@ describe('globals', () => {
expect(doc).toMatchObject(data)
})
it('should not show globals with disabled graphql', async () => {
const query = `query {
WithoutGraphql { __typename }
}`
await expect(client.request(query)).rejects.toHaveProperty('message')
})
})
})