Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataSources is not working #15

Open
iEricKoh opened this issue Sep 26, 2018 · 0 comments
Open

dataSources is not working #15

iEricKoh opened this issue Sep 26, 2018 · 0 comments

Comments

@iEricKoh
Copy link

iEricKoh commented Sep 26, 2018

I am trying follow the official doc to use data source in my resolvers.
However, there's no field name dataSources exists on context.

I am wondering if the dataSources is acceptable when I try to register the plugin?

const resolvers = {
  Query: {
    product: async (_source: any, args: any, context: any) => {
      console.log(args)
      console.log(context) // no dataSources in the context
      return {
        id: 1
      }
    }
  },
};
    server.register(graphqlFastify, { 
      prefix: '/graphql', 
      graphql: {
        schema,
        dataSources: () => {
          console.log('The log doesn\'t print')
          return {
            productAPI: new ProductAPI(),
          };
        },
        context: () => {
          return {
            token: 'foo',
          };
        },
        tracing: true,
        cacheControl: {
          defaultMaxAge: 500,
          stripFormattedExtensions: false,
          calculateCacheControlHeaders: false,
        },
        cache: new RedisCache({
          host: '127.0.0.1'
        })
      },
    });

https://www.apollographql.com/docs/apollo-server/features/data-sources.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant