fix: GraphQL introspection disabled in NODE_ENV=production even with master key (#10071)

This commit is contained in:
Antoine Cormouls
2026-02-23 14:32:12 +00:00
committed by GitHub
parent 3148b5fa7b
commit a5269f0776
2 changed files with 52 additions and 8 deletions
+49 -7
View File
@@ -685,9 +685,16 @@ describe('ParseGraphQLServer', () => {
}
});
it('should always work with master key', async () => {
const introspection =
await apolloClient.query({
it('should always work with master key in node environment production', async () => {
const originalNodeEnv = process.env.NODE_ENV;
try {
// Apollo Server have changing behavior based on the NODE_ENV variable
// so we need to set it to production to get the expected behavior
// and cover correctly the introspection cases
process.env.NODE_ENV = 'production';
await createGQLFromParseServer(parseServer);
const introspection = await apolloClient.query({
query: gql`
query Introspection {
__schema {
@@ -701,10 +708,45 @@ describe('ParseGraphQLServer', () => {
headers: {
'X-Parse-Master-Key': 'test',
},
}
},)
expect(introspection.data).toBeDefined();
expect(introspection.errors).not.toBeDefined();
},
});
expect(introspection.data).toBeDefined();
expect(introspection.errors).not.toBeDefined();
} finally {
process.env.NODE_ENV = originalNodeEnv;
}
});
it('should always work with master key in node environment development', async () => {
const originalNodeEnv = process.env.NODE_ENV;
try {
// Apollo Server have changing behavior based on the NODE_ENV variable
// so we need to set it to development to get the expected behavior
// and cover correctly the introspection cases
process.env.NODE_ENV = 'development';
await createGQLFromParseServer(parseServer);
const introspection = await apolloClient.query({
query: gql`
query Introspection {
__schema {
types {
name
}
}
}
`,
context: {
headers: {
'X-Parse-Master-Key': 'test',
},
},
});
expect(introspection.data).toBeDefined();
expect(introspection.errors).not.toBeDefined();
} finally {
process.env.NODE_ENV = originalNodeEnv;
}
});
it('should always work with maintenance key', async () => {
+3 -1
View File
@@ -147,7 +147,9 @@ class ParseGraphQLServer {
// needed since we use graphql upload
requestHeaders: ['X-Parse-Application-Id'],
},
introspection: this.config.graphQLPublicIntrospection,
// We need always true introspection because apollo server have changing behavior based on the NODE_ENV variable
// we delegate the introspection control to the IntrospectionControlPlugin
introspection: true,
plugins: [ApolloServerPluginCacheControlDisabled(), IntrospectionControlPlugin(this.config.graphQLPublicIntrospection)],
schema,
});