diff --git a/docs/settings.md b/docs/settings.md index bafa35d..9229324 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -37,7 +37,9 @@ initialize({ // You must not override schema // You can add `schemaDirectives` and `context` without worrying about context update - schemaDirectives: [MyCustomDirective], + schemaDirectives: { + MyCustomDirective, + }, context: async () => ({ services }) diff --git a/server/initialize.js b/server/initialize.js index 2173c5a..f2d8825 100644 --- a/server/initialize.js +++ b/server/initialize.js @@ -30,6 +30,12 @@ export default function initialize(apolloConfig = {}, meteorApolloConfig = {}) { const { typeDefs, resolvers } = getSchema(); const initialApolloConfig = Object.assign({}, apolloConfig); + + const schemaDirectives = { + ...defaultSchemaDirectives, + ...(initialApolloConfig.schemaDirectives ? initialApolloConfig.schemaDirectives : {}), + }; + apolloConfig = { introspection: Meteor.isDevelopment, debug: Meteor.isDevelopment, @@ -46,12 +52,7 @@ export default function initialize(apolloConfig = {}, meteorApolloConfig = {}) { ...initialApolloConfig, typeDefs, resolvers, - schemaDirectives: { - ...defaultSchemaDirectives, - ...(initialApolloConfig.schemaDirectives - ? initialApolloConfig.schemaDirectives - : []), - }, + schemaDirectives, context: getContextCreator(meteorApolloConfig, initialApolloConfig.context), subscriptions: getSubscriptionConfig(meteorApolloConfig), };