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.

Remote schema type merging

See original GitHub issue

Hi!

I need to be able to return hasura types from my remote schema, so that the apollo client can automatically refresh its cache without having to do a second graphql call (one of the main advantages of apollo client!)

I’m building my remote schema with Apollo like this:

  const localExecutableSchema = makeExecutableSchema({
    typeDefs: localSchema
  })

  const hasuraTypeDefs = fs.readFileSync(path.join(__dirname, "schema.graphql"), "utf8")

  const remoteExecutableSchema = makeExecutableSchema({
    typeDefs: hasuraTypeDefs
  })

  const newSchema = mergeSchemas({
    schemas: [
      localExecutableSchema,
      remoteExecutableSchema,
    ],
    resolvers: resolvers
  })

I downloaded the types from Hasura like this:

gq http://localhost:8080/v1/graphql -H 'X-Hasura-Admin-Secret: *********' --introspect > schema.graphql


It’s definitely loading all the types into apollo-server 🎉, but then I get this error from Hasura. What’s happening here? Is there some way to disable the aggregate fields other than editing the file? Or some way to make apollo-server/Hasura deal with these types?

graphql-engine_1  | {"timestamp":"2019-07-09T12:30:50.027+0000","level":"warn",
"type":"metadata","detail":{"message":"Inconsistent Metadata!",
"info":{"objects":[{"definition":{"definition":{"url":null,"headers":[],"url_from_env":"NODE_SCHEMA_URL","forward_client_headers":true},"name":"node-server","comment":null},
"reason":"types: [ 
profile_responses_aggregate_fields, 
slides_aggregate_fields, 
user_notification_preferences_aggregate_fields, 
users_public_aggregate_fields, 
..., <and so on, all "aggregate" fields for every table> ] 
have mismatch with current graphql schema. HINT: Types must be same.","type":"remote_schema"}]}}}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
michaelhaymancommented, Jul 14, 2019

So from my remote schema I return an ID, and then I can use that to do a join in Hasura via remote schemas.

I think this would work perfectly, if it also works for mutations 😃

1reaction
JCMaiscommented, Jan 12, 2021

@tejasmanohar The new Actions feature allows you to create custom mutations and connect it with the rest of the graph. See https://hasura.io/docs/1.0/graphql/manual/actions/action-connect.html

@tirumaraiselvan so this is not possible with remote schemas alone?

Are there plans to create a remote join for remote schemas? Just like there is for actions?

Example: Mutation UpdateUser in the remote schema returns an author_id: ID field, we are then able to create an updatedUser in Hasura using a remote join from UpdateUser.author_id to the table users.id.

If there is an issue with this, please do let me know, as this was the only one I found. If you think it’s better to create a separated issue, let me know.

I find it counter-intuitive having to add an Action for this, as I’m already using a remote schema.

Edit: Looks like there is already an issue for this: https://github.com/hasura/graphql-engine/issues/5801

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type Merging – GraphQL Tools
Type merging allows partial definitions of a type to exist in any subschema, all of which are merged into one unified type in...
Read more >
Adding a Remote Schema | Hasura GraphQL Docs
Top-level field names need to be unique across all merged schemas (case-sensitive match). Types with the exact same name and structure will be...
Read more >
ERROR: Configuration exception merging remote schema
The good news is the schema disagreement is fixed by performing a rolling restart on the cluster. After all the nodes have been...
Read more >
Schema Stitching - Hot Chocolate v10
Schema stitching is the capability to merge multiple GraphQL schemas ... those types having any representation in any of the remote schemas.
Read more >
Understanding schema stitching in GraphQL - LogRocket Blog
In this tutorial, you can learn what schema stitching is, ... Stitching remote subschemas; Type merging for stitched schemas ...
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