This prototype is just a fun side project in an effort to learn Schema Stitching. I'll continue to add more to this project as I learn more about schema stitching to showcase its functionality.
As a disclaimer, I am new to Javascript so expect to cringe when looking through my code
- Adding subschema definitions from a local file
- Adding subschema definitions remotely using Introspection
- Creating new Types on the stitched gateway and using Resolvers to resolve that data for the new type
- Extending Types coming from Subschemas and adding Resolvers to handle it
- Something cool to note, we extended the teammate Type from the Team GraphQL and added the contact details from the Contact GraphQL.
- Creating new mutations on top of existing mutations
- Adding selection sets when delegating to schema to ensure we get certain elements even if the client didn't request them.
- Custom Scalar Types for id validation.
- Adding Authorization
- Further expanding on Custom Scalar Types
Be sure to download the other three Projects below
- Nintendo Team GraphQL API:
- Can be found here
- will be running on
http://localhost:8081/nintendo/team/graphql
- Nintendo Contact GraphQL API:
- Can be found here
- will be running on
http://localhost:8082/nintendo/contact/graphql
- Nintendo Project GraphQL API:
- Can be found here
- will be running on
http://localhost:8083/nintendo/project/graphql
cd fun-with-graphQL-schema-stitching
yarn install
yarn start
Visit the GraphQL Playground interface for the stitched gateway to mess around with the mutations and queries.
Below is an example for querying all Nintendo Employee Details. Checkout the attached Postman Collection for more examples.
GraphQL Query
query allData($nintendoId: NintendoId!,
$includeName: Boolean!, $includeTeam: Boolean!, $includeProjects: Boolean!,
$includeContact: Boolean!, $includeAddress: Boolean!, $includePhone: Boolean!, $includeEmail: Boolean!){
employeeData(nintendoId: $nintendoId) {
nintendoId
name @include(if: $includeName) {
...fullName
}
teamInfo {
teamName
}
teammates @include(if: $includeTeam) {
teamId
nintendoId
details {
name {
...fullName
}
...contact
}
}
projects @include(if: $includeProjects) {
projectName
status
franchise {
title
}
}
...contact
}
}
fragment fullName on Name {
firstName
middleName
lastName
}
fragment contact on NintendoEmployee {
contactInformation @include(if: $includeContact) {
emails @include(if: $includeEmail) {
emailAddress
purpose
}
phones @include(if: $includePhone) {
number
type
}
addresses @include(if: $includeAddress) {
country
streetAddress
cityName
stateProvince
postalCode
}
}
}
Variables
{
"nintendoId": "nin0001",
"includeName": true,
"includeTeam": true,
"includeContact": true,
"includeAddress": true,
"includePhone": true,
"includeEmail": true,
"includeProjects": true
}
The results of this query are retrieved from the underlying subschemas by the stitched gateway.
name
andteammates
come from the remote Nintendo Team server.address
,phone
, andemail
come from the remote Nintendo Contact server.project
andfranchises
come from the remote Nintendo Project server.