question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getRemoteSchema - function proposal

See original GitHub issue

I think it would be useful to have such function in graphql-yoga:

export async function getRemoteSchema(uri) {
    const link = new HttpLink({ uri, fetch })
    const introspectionSchema = await introspectSchema(link);
    const graphcoolSchema = makeRemoteExecutableSchema({
        schema: introspectionSchema,
        link
    });

    return graphcoolSchema;
}

To create easily remote schemas and merge them all.

What do you think?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
playerxcommented, Dec 19, 2017

@schickling I’ve created new project @jokio/graphql, it’s graphql server, built on top of graphql-yoga. This package will solve my domain specific problems, but for now there are more generic solutions.

Here is the example of complex scenario:

  • stitch remote schemas
  • split your local code to multiple little schemas
  • working with rest apis

example: https://github.com/jokio/graph/blob/master/src/index.ts

Please check out and if you will like any ideas I can send pull request.

Discussion

I’ve found two main issues while I was developing my package and I want to discuss:

  1. I need this code to be async, because I’m going to make authentication if user will enable it.

  2. graphql-yoga creates context for web sockets per operation (onOperation) and I need it to be created only once when user connects (onConnect), based on connectionParams. What was the reason of using onOperation?

2reactions
playerxcommented, Dec 14, 2017

My use case is to have graphql micro-services: Users, Roles, Game1, Game2, Payments and to stitch them together like that: (urls are mock)

const usersSchema = await getRemoteSchema('https://users.jok.io/graphql');
const rolesSchema = await getRemoteSchema('https://roles.jok.io/graphql');
const game1Schema = await getRemoteSchema('https://game1.jok.io/graphql');
const game2Schema = await getRemoteSchema('https://game2.jok.io/graphql');
const paymentsSchema = await getRemoteSchema('http://payments.jok.io/graphql');

const typeDefs = `...`
const resolvers = {...}

const schema = mergeSchemas({
  schemas: [usersSchema, rolesSchema, game1Schema, game2Schema, paymentsSchema, typeDefs],
  resolvers: resolvers
});

...
Read more comments on GitHub >

github_iconTop Results From Across the Web

getRemoteSchema - function proposal · Issue #28
Here is the example of complex scenario: stitch remote schemas; split your local code to multiple little schemas; working with rest apis.
Read more >
Remote Schemas – GraphQL Tools
Generate GraphQL schema objects that delegate to a remote server.
Read more >
Learn how GraphQL remote schemas work?
A GraphQL execution engine is a program (or function) that, given an executable schema and a query (or mutation), produces a valid response....
Read more >
playerx (Ezeki Zibzibadze) · GitHub - ramyasenthilarts.com
Plan and track work ... By Plan; Enterprise · Teams · Compare all ... Date, Time, JSON - scalars proposal Dec 14; getRemoteSchema...
Read more >
The graphql-yoga from dotansimha - GithubHelp
getRemoteSchema - function proposal. I think it would be useful to have such function in graphql-yoga: export async function getRemoteSchema(uri) { const ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found