Skip to content

A complete working example for Apollo Federation using dotnet/graphql

Notifications You must be signed in to change notification settings

Tall-Paul/dotnetGqlFederation

Repository files navigation

Complete example of GraphQL Federation with implementing services written using graphql-dotnet and the ASP.Net middleware package

implementing services: Users Products Baskets

Users and Products services don't know anything about the other services. Baskets only knows about User IDs and Product IDs (it uses them as foreign keys to link those entities to the baskets)

clone this repo docker-compose up

open graphql playground in a browser: http://localhost:8080

run this query:

{
  User: userByUsername(username:"@ada"){
    name
    address {
      postCode
    }
    basket {
      products {
        name
        description
        price
      }
    }    
  }
}

You should get back:

 {
  "data": {
    "User": {
      "name": "Ada Lovelace",
      "address": {
        "postCode": "BL1 6DD"
      },
      "basket": {
        "products": [
          {
            "name": "White Keyboard",
            "description": "A keyboard.  For typing on and that.  It's white",
            "price": 10.99
          },
          {
            "name": "White Mouse",
            "description": "A mouse.  For moving a cursor. And clicking.  It's white",
            "price": 5.99
          }
        ]
      }
    }
  }

marvel at the data coming from each service and being seamlessly joined together.

About

A complete working example for Apollo Federation using dotnet/graphql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published