Giter Site home page Giter Site logo

graphql-custom-resolver-example's Introduction

GraphQL Custom Resolver Example

A simple example of using a custom resolver with Hasura's GraphQL API. We combine Hasura GraphQL and a simple hello world schema by Schema Stitching.

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 any schema.

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 server. 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 Hasura GraphQL API, with the schema
  2. A simple hello world schema.
# Get hello
query {
  hello
}

# Get data from Hasura Data API
query fetch_author {
  author {
    id
    name
  }
}

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

query {
    hello 
    author {
       id
       name
    }
}

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.