Skip to content

This demo uses the Graphcool API Gateway pattern to reuse common functionality in multiple projects

License

Notifications You must be signed in to change notification settings

kbrandwijk/graphcool-gateway-common-features

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphcool-gateway-common-features

This demo uses the Graphcool API Gateway pattern to reuse common functionality in multiple projects. It uses a common Graphcool service that provides weather information, and makes it available through schema stitching in another project that holds address information. This pattern is useful for all kinds of common features (weather, directions, mail sending etc.) that you can now easily reuse across projects.

Architecture

One service holds information about users and their addresses according to this schema:

type User @model {
  id: ID! @isUnique
  name: String!
  dateOfBirth: DateTime
  address: Address @relation(name: "UserAddress")
}

type Address @model {
  id: ID! @isUnique
  city: String!
  user: User @relation(name: "UserAddress")
}

The other service just contains one resolver function:

type WeatherPayload {
  temperature: Float
}

extend type Query {
  getWeatherByCity(city: String): WeatherPayload
}

This application (the API Gateway) stitches them together, by extending the Address Type with a weather field.

Running this example

The easiest way to run this example is to use the Apollo Launchpad: https://launchpad.graphql.com/9q0nxlk9r

Local development

  • Create a .env file in the root of your project folder with the following keys:
    • GRAPHCOOL_ADDRESS_ENDPOINT
    • GRAPHCOOL_WEATHER_ENDPOINT
GRAPHCOOL_ADDRESS_ENDPOINT=https://api.graph.cool/simple/v1/...
GRAPHCOOL_ADDRESS_ENDPOINT=https://api.graph.cool/simple/v1/...

If you don't provide these keys, the application will use demo endpoints (read-only)

image

About

This demo uses the Graphcool API Gateway pattern to reuse common functionality in multiple projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published