Graphql-yoga: dataSources option for rest apis

Created on 2 Jul 2018  路  10Comments  路  Source: dotansimha/graphql-yoga

Is there any way I can provide dataSources for rest apis

e.g With ApolloServer it can be done as -

const server = new ApolloServer({
  typeDefs,
  resolvers,
  dataSources: () => {
    return {
      moviesAPI: new MoviesAPI(),
      personalizationAPI: new PersonalizationAPI(),
    };
  },
  context: () => {
    return {
      token: 'foo',
    };
  },
});

Most helpful comment

Can pass through context

const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: () => ({
   dataSources: () => {
    return {
      moviesAPI: new MoviesAPI(),
      personalizationAPI: new PersonalizationAPI(),
    };
  },
  }),
});

All 10 comments

Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.

Hey :wave:, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of graphql-yoga we'll close it.
Feel free to reopen it at any time if you believe we should futher discuss its content. :slightly_smiling_face:

Does anyone know if 'data sources' can be used in graphql-yoga? I can't get it to show up on the context argument.

Very interested in an answer to this question. Does anyone know how to use data sources with graphql-yoga?

Looking for a way to use apollo-datasource-rest with graphql-yoga. I don't think there's the interface for integration. Anyone knows something...?

Looking for a way to use apollo-datasource-rest with graphql-yoga. I don't think there's the interface for integration. Anyone knows something...?

@japboy seems like this is not possible with Yoga. I wound up switching my server to Apollo Server 2 so I could use it.

Sent with GitHawk

I wound up switching my server to Apollo Server 2 so I could use it.

that sounds better rather than stucking here. thanks @marcimmediato

Any support for this feature.? I am blocked for now :(

Can pass through context

const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: () => ({
   dataSources: () => {
    return {
      moviesAPI: new MoviesAPI(),
      personalizationAPI: new PersonalizationAPI(),
    };
  },
  }),
});

@kesonseek Thanks to your clue, I was able to get apollo-datasource-rest works with graphql-yoga.

You can see my comments about it here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshhopkins picture joshhopkins  路  3Comments

ramonmulia picture ramonmulia  路  3Comments

anthonymetzler picture anthonymetzler  路  4Comments

lautiamkok picture lautiamkok  路  4Comments

marktani picture marktani  路  5Comments