schema-stitching-examples
This repo is a set of different examples illustrating different use cases of schema stitching.
This repo is a set of different examples illustrating different use cases of schema stitching.
Thanks for sharing these examples, they're v. useful!
I've run into an issue within my own project which I think is also present in your schema-extension example.
In short, the following operation will fail to return city_weather
:
query GetUser {
user(id: 1) {
city_weather {
temp
}
}
}
The reason this fails is because the city_weather
resolver depends on parent.city
but does not receive it because it's not in the selection set sent to the remote user schema.
Currently I'm just throwing an exception if city_weather
is selected without city
but this isn't ideal and wondered if you have any thoughts on how one might solve this?
I had thought it might be possible to create a @dependsOn
directive which could add city
to the query being made to the remote schema, but I don't think field directives can manipulate the parent query or resolvers.
extend type user {
city_weather: city_weather @dependsOn(field: "city")
}
The primary GraphQL endpoint used in the examples is broken:
https://bazookaand.herokuapp.com/v1alhpa1/graphql
ENDPOINT DEAD
Returns Heroku's standard Application Error response.
Edit: Actually it's just a typo in a code block in the blog article v1alhpa1
โ v1alpha1
= ๐
For each of the examples, getting GraphQLError: Syntax Error: Expected Name, found }
after running npm install
followed by npm start
.
(node:51878) UnhandledPromiseRejectionWarning: GraphQLError: Syntax Error: Expected Name, found }
at syntaxError (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/error/syntaxError.js:24:10)
at expect (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:1299:32)
at parseName (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:92:15)
at parseFieldDefinition (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:809:14)
at many (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:1348:16)
at parseFieldsDefinition (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:799:50)
at parseObjectTypeDefinition (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:757:16)
at parseTypeSystemDefinition (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:663:16)
at parseDefinition (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:143:16)
at parseDocument (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:110:22)
at Object.parse (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql/language/parser.js:38:10)
at Object.buildSchemaFromTypeDefinitions (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js:20:33)
at Object.makeExecutableSchema (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql-tools/dist/makeExecutableSchema.js:27:29)
at makeRemoteExecutableSchema (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/node_modules/graphql-tools/dist/stitching/makeRemoteExecutableSchema.js:134:35)
at createUserSchema (/Users/br/Library/Mobile Documents/com~apple~CloudDocs/dev/tutorials/graphql/schema-stitching-examples/new-queries-mutations/index.js:30:10)
at <anonymous>
(node:51878) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:51878) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The unhandled promise error is a separate issue as far as I can tell.
System: macOS Version 10.13.6 (17G3025)
Node Version: 9.4.0
I wonder if it's to do with a recent upstream node package upgrade?
Hi, I have followed your examples (good job) but I was searching for how remove some queries or mutations in a proxy server which is getting a remote schema from the main server.
Do you know if is it possible do it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.