fix: handle graphQL: false on globals when building policy type (#3729)
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -80,6 +80,12 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: 'without-graphql',
|
||||
access,
|
||||
graphQL: false,
|
||||
fields: [],
|
||||
},
|
||||
],
|
||||
onInit: async (payload) => {
|
||||
await payload.create({
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user