Giter VIP home page Giter VIP logo

federated-api-demo's Introduction

federated-api-demo

Demo of a federated graphql api with all services and gateway collocated.

A federated graph is one that is comprised of one or more subgraphs, which run in separate servers–essentially graphql microservices. The gateway is responsible for exposing a unified graph and ensuring that fields in queries and mutations reach the correct subgraphs.

The demo contains the following:

  • gateway
  • subgraphs
    • user subgraph
    • commit subgraph

Each subgraph, and the gateway, is exposed on a different port on the same host.

User subgraph

The user subgraph defines a User type:

type Query {
  me: User
  user(id: ID!): User
  users: [User]
}

type User @key(fields: "id") {
  id: ID!
}

Commit subgraph

The commit subgraph defines a new Commit type and extends the User type:

type Query {
  commit(id: ID!): Commit
  commits: [Commit]
}

type Mutation {
  commitCreate(input: CommitCreateInput!): CommitCreatePayload
}
input CommitCreateInput {
  message: String!
}
type CommitCreatePayload {
  commit: Commit
}

type Commit @key(fields: "id") {
  id: ID!
  sha: String
  short: String
  message: String
  user: User
}

type User @key(fields: "id") {
  id: ID!
  commits: [Commit]
}

Run the demo

Start the gateway by running npm run dev. You can then run queries against it like so:

image

image

federated-api-demo's People

Contributors

jxdp avatar

Watchers

 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.