Remote schema type merging
See original GitHub issueHi!
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:
- Created 4 years ago
- Reactions:4
- Comments:21 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 😃
@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 anauthor_id: ID
field, we are then able to create anupdatedUser
in Hasura using a remote join fromUpdateUser.author_id
to the tableusers.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