Coder Social home page Coder Social logo

federation-demo's Introduction

Strawberry Apollo Federation demo

This repo contains a demo of Strawberry's Apollo Federation support.

It contains 3 services:

  1. A books service
  2. A reviews service
  3. A gateway service

Books

The books service provides a GraphQL API that returns a list of books.

Reviews

The reviews service provides a GraphQL API that only extends the Book type (coming from the books service) with a reviews field.

The reviews field is a list of reviews for the book.

Gateway

The gateway service provides a GraphQL API that combines the books and reviews. It is implemented with Apollo Server and Apollo Gateway.

Schema

Graphical representation of the schema described above

Running the demo

For convenience we provided a docker-compose file that can be used to run the whole demo.

Before being able to run the demo you need the following environment variables, in both .env and gateway/.env:

APOLLO_KEY=...
APOLLO_GRAPH_REF=...

You can get these values by creating a new service in Apollo Studio. You can follow the instructions here: https://www.apollographql.com/docs/studio/getting-started/

Once you have the environment variables set, you can upload the schema to Apollo Studio by running:

make publish

Assuming you have docker and docker compose installed you can run the following command to start the demo:

docker-compose up

This should start all the services and you should be able to access the GraphQL API at http://localhost:4000/graphql.

federation-demo's People

Contributors

estyxx avatar patrick91 avatar pre-commit-ci[bot] avatar

Stargazers

 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  avatar

federation-demo's Issues

Errors in starting docker-compose

I'm getting the following errors when i start with docker-compose up
...
books_1 | field = StrawberryField(
books_1 | File "/usr/local/lib/python3.10/site-packages/strawberry/field.py", line 56, in init
books_1 | super().init( # type: ignore
books_1 | TypeError: Field.init() missing 1 required positional argument: 'kw_only'
....
reviews_1 | field = StrawberryField(
reviews_1 | File "/usr/local/lib/python3.10/site-packages/strawberry/field.py", line 56, in init
reviews_1 | super().init( # type: ignore
reviews_1 | TypeError: Field.init() missing 1 required positional argument: 'kw_only'
...
gateway_1 | Polling running services is dangerous and not recommended in production. Polling should only be used against a registry. If you are polling running services, use with caution.
gateway_1 | โŒ Unable to start gateway Error: Couldn't load service definitions for "books" at http://books:8000/graphql: request to http://books:8000/graphql failed, reason: connect ECONNREFUSED 172.26.0.2:8000
gateway_1 | at /app/node_modules/@apollo/gateway/src/loadServicesFromRemoteEndpoint.ts:73:15
gateway_1 | at processTicksAndRejections (node:internal/process/task_queues:96:5)
gateway_1 | at async Promise.all (index 0)
gateway_1 | at async Object.getServiceDefinitionsFromRemoteEndpoint (/app/node_modules/@apollo/gateway/src/loadServicesFromRemoteEndpoint.ts:77:30)
gateway_1 | at async ApolloGateway.updateSchema (/app/node_modules/@apollo/gateway/src/index.ts:423:20)
gateway_1 | at async ApolloGateway.loadDynamic (/app/node_modules/@apollo/gateway/src/index.ts:403:7)
gateway_1 | at async ApolloGateway.load (/app/node_modules/@apollo/gateway/src/index.ts:361:9)
gateway_1 | [nodemon] clean exit - waiting for changes before restart

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.