mseimys / graphy

GraphQL Testbed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQL Testbed

Uses Ariadne for schema-first GraphQL in Python. Apollo for React is used to bind frontend to GraphQL.

UI

Running

#<-- activate virtualenv if you are using it
pip install -r requirements.txt
npm install
npm start

Navigate to http://localhost:3000 to see frontend. Use http://localhost:8000/graphql/ to directly access GraphQL playground. Two commands have been launched in parallel in the background:

./manage.py runserver 0.0.0.0:8000   # Runs Python GraphQL backend
webpack-dev-server                   # Runs React+Webpack+TypeScript frontend, proxies :3000/graphql/ to :8000/graphql/

Sample Queries and Mutations

Queries

{
  category(id: 4) {
    id
    name
  }
}
{
  ingredients(limit: 10) {
    id
    name
    category {
      id
      name
    }
  }
}

Mutations

mutation {
  deleteCategory(id: 123)
}
mutation {
  createCategory(name: "Abrakadabra") {
    id
    name
  }
}
mutation createIngredient($input: IngredientInput!){
  createIngredient(input: $input) {
    id
    name
  }
}

# Pass variables

{
  "input": {
    "name": "Beer",
    "categoryId": "5"
  }
}

Subscriptions

subscription {
  counter
}

About

GraphQL Testbed


Languages

Language:Python 60.7%Language:TypeScript 28.0%Language:HTML 5.7%Language:JavaScript 5.5%