Skip to content

Latest commit

 

History

History
78 lines (61 loc) · 1.89 KB

settings.md

File metadata and controls

78 lines (61 loc) · 1.89 KB

Settings

// server
import { initialize } from 'meteor/cultofcoders:apollo';

initialize(ApolloConstructorOptions?, MeteorApolloOptions?);

// quickest way:
initialize();

Quick Tip: Engine

If you want to use engine GraphQL monitoring tool:

// server
initialize(
  {},
  {
    engine: {
      apiKey: "XXX"
    }
  }
);

ApolloConstructorOptions

https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#constructor-options-lt-ApolloServer-gt

Do not override schema.

MeteorApolloOptions

// server
initialize({
  // Here you can provide the apollo options provided here:
  // https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#constructor-options-lt-ApolloServer-gt

  // You must not override schema

  meteorAccounts: true, // You can disable reading the users via Meteor accounts
  // You can add `schemaDirectives` and `context` without worrying about context update
  schemaDirectives: {
    MyCustomDirective,
  },
  // You get access to db, user, userId inside the resolver.
  context: async ({ db, user, userId }) => ({
    services
  })
}, {
  // This is just an example, you have cors built in ApolloOptions
  // You can also add other connect middlewares to '/graphql' endpoint
  middlewares: [],

  // GUI, because we're using an express middleware to connect with our WebApp, gui configuration is done at that level
  // So basically the `gui` config from `ApolloConstructorOptions` will be ignored
  gui: Meteor.isDevelopment

  // Because we support authentication by default
  // We inject { user, userId } into the context
  // These fields represent what fields to retrieve from the logged in user on every request
  // You can use `undefined` if you want all fields
  userFields: {
    _id: 1,
    username: 1,
    emails: 1,
    roles: 1,
  },
});