Skip to content

SultanBadri/simple-express-graphql-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-express-graphql-server

A simple Express.js and GraphQL server with recipes.

How to run

First, clone the repository.

git clone https://github.com/SultanBadri/simple-express-graphql-server.git

Now run these commands to start the GraphQL server at http://localhost:4000/graphql.

cd simple-express-graphql-server
npm install
node index.js

To search in GraphiQL

To get all of the recipes.

{
  recipes {
    id
    title
    description
    instructions
    cookTime
    ingredients
  }
}

To get recipe with id 1.

{
  recipe(id : 1) {
    id
    title
    description
    instructions
    cookTime
    ingredients
  }
}

Using a query variable to get a certain recipe via its id.

query getRecipe($recipeId: ID!) {
  recipe(id: $recipeId) {
    id
    title
    description
    instructions
    cookTime
    ingredients
  }
}

NOTE: Make sure to declare a variable $recipleId in the Query Variables panel of GraphiQL.

{
  "recipeId": 3
}

About

A simple Express.js and GraphQL server with recipes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published