graphql-prisma-yoga-demo

GraphQL demo yoga with prisma backend

MIT License

Stars
0

GraphQL Yoga demo

This example shows how you can simply map one GraphQL model to another and how you can combine tow models to one GraphQL model using Yoga

TL:TR

git clone https://github.com/npalm/graphql-prisma-demo.git --recurse-submodules
./start.sh

Now point your browser to the GraphQL Playground

Introduction

This GraphQL demo is using yoga to combine the GraphQL model of two applications build using Prisma. The first application has a domain model of conferences, talks, speakers and comments. The second application is a touristy information model that is currently limited to store information about cities and some craft beer bars.

The conference app

The conference app can store information about talks and speakers on a conference based on the next model. model-talks

After starting the demo you can access this service via http://localhost:4466/ and execute a query like.

query {
  conferences {
    name
    city
    talks {
      title
      speakers {
        name
      }
    }
  }
}

The touristy app

The touristy app can store cities and some cool bars based on the next model.

After starting the demo you can access this service via http://localhost:4467/ and execute a query like.

query {
  cities {
    name
    bars {
      name
    }
    restaurants {
      name
      cuisine
    }
  }
}

Yoga app

With the yoga app we combine the model to one model. So you can find for the city where a conference is some touristy information. Besides that the conference app is actually based on a Spring Boot GraphQL example. Which has a slight different schema. The schema of the conference app is generated via prisma based on a data structure. With yoga we can map the schema on one of our choice. In this case the same as used in the Spring Boot example.

After starting the demo you can access this service via http://localhost:4000/ and execute a query like.

query {
  conferences {
    name
    location {
      name
      bars {
        name
      }
      restaurants {
        name
        cuisine
      }
    }
  }
}

Required software

  • Node 10+
  • docker and docker-compose

Start

Just run the start script, it will spin up docker containers for prisma and the database. Once up, prisma is deployed and some data is loaded via npm.

./start.sh

Stop (clean)

Just run the stop script.

./stop.sh