Giter Club home page Giter Club logo

graphql-schema-stitching-demo's Introduction

GraphQL Schema Stitching Demo

Schema stitching is the process of creating a single GraphQL schema from multiple underlying GraphQL APIs.

Schema stitching allows you to have one unified API that allows the client to query multiple GraphQL Schemas at the same time, including relations between the schemas.

Prerequisites

This demo requires Hasura's GraphQL Engine running with the following schema: A table called Person with columns id, name, and city.

Usage

npm install
HASURA_GRAPHQL_ENGINE_URL=http://localhost:9000 npm start

Change the HASURA_GRAPHQL_ENGINE_URL environment variable to point to a hasura graphql-engine with the person schema. Then, open localhost:8080/graphiql in your web browser, and start exploring with your query.

Merge Schemas

This demo combines two GraphQL schemas and exposes them on a single API:

  1. The public GraphQL API of Meta Weather, to fetch the temperature information for a given city. Explore this on Apollo Launchpad
  2. The Hasura GraphQL API, having a table called Person with columns id, name and city.
# Get weather info
query {
  cityWeather(city_name: "Bangalore") {
    city_name
    temp
    min_temp
    max_temp
    applicable_date
  }
}

# Get person data from Hasura Data API
query fetch_person {
  person {
    id
    name
    city
  }
}

We can extend the persons city column to include weather information.

extend type person {
  city_weather: CityWeather
}

Now this can be merged and queried using the same API like:

query {
    person {
       id
       name
       city
       # fetching weather after schema stitching
       city_weather {
        city_name
        temp
        min_temp
        max_temp
        applicable_date
      }
    }
}

graphql-schema-stitching-demo's People

Contributors

praveenweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.