mirror of
https://github.com/parse-community/parse-server
synced 2026-08-09 13:03:18 +00:00
fix: GraphQL introspection disabled in NODE_ENV=production even with master key (#10071)
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user