Skip to content

A simple game graphql api server to practice building a graphql server using node.js

Notifications You must be signed in to change notification settings

amarachigoodness74/games-GraphQL-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This is a simple GraphQL API server that allows a user to access associated data of a game which includes Game, Author and Review.
Here, a file system was used as a database to keep it simple and focus on learning GraphQL but any database of choice can be used.

Installation

Fork this repo to have the repository in your GitHub account
Clone the repository and cd into the project directory
Run npm install or yarn install to install all project dependencies
Run npm start or yarn start to start local server which will run on http://localhost:4000/

To run test, run:
NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" npx jest

Usage

Query Samples

query ExampleQuery {
  authors {
    name
    verified
    reviews {
      rating
      content
    }
  }
  games {
    title
    platform
    reviews {
      rating
      content
    }
  }
  reviews {
    rating
    content
    game {
      platform
    }
    author {
      id
      name
    }
  }
}
query SingleQuery ($id: ID!){
  author(id: $id) {
    name
    verified
    reviews {
      rating
      content
    }
  }
}

Query Result

{
  "data": {
    "author": {
      "name": "Charles",
      "verified": true,
      "reviews": [
        {
          "rating": 2,
          "content": "Was good"
        }
      ]
    }
  }
}
mutation SingleMutation ($author: AddAuthorInput!){
  addAuthor(author: $author) {
    name
    verified
    reviews {
      rating
      content
    }
  }
}

Mutation Result

{
  "data": {
    "addAuthor": {
      "name": "John Doe",
      "verified": true,
      "reviews": []
    }
  }
}

Built With

Node.js - The web tool used
@apollo/server - To create GraphQL API seamlessly

Contributing:

To contribute, raise an issue and it will be reviewed

Author

Amarachi Goodness

License

This project is licensed under the ISC License

About

A simple game graphql api server to practice building a graphql server using node.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published