Coder Social home page Coder Social logo

graphql-hotels-example's Introduction

graphql-hotels-example

Tired of TodoMVC? So do I.

What is it?

This is yet another example of GraphQL server. It provides you GraphQL backend, so you can play with queries in the GraphiQL. While implementing this example I was trying to keep backend simple but provide clear and meaningful schema.

Features

  • To keep it simple this example uses in-memory storage. Initial data located in data.json file.
  • GraphiQL tool enabled and it is a way to play with GraphQL.
  • There is no frontend part. (But it would be good to implement example clients using Relay. react-native example in progress.)

Domain, Diagram and Schema. Small Intro.

What is our app about?

Let's imagine we are developing tourist guide program.

  • There is information about Countries our user may plan to visit.
  • Each Country contains Cities.
  • And each City has a bunch of Hotels.

Wait, what the backend without nice images? We will add Image to Country and list of Images for each City.

Now we can review the Relations Diagram.

Relations Diagram

relations diagram

Schema

Our schema allow us to fetch any shape of data. For this we need to add entry points for lists and individual entity:

  • countries - List of Countries. For index page of our application with countries.
  • country(countryID) - Particular Country by ID. For individual Country page.
  • city(cityID) - Particular City by ID. For individual City page.
  • hotel(hotelID) - Particular Hotel by ID. For individual Hotel page.
About node entry point.

Have you noticed some kind of duplication in country, city, hotel? For avoiding this Relay provides us ability to use one entry point for all individual entities called node:

  • node(ID) - Where ID is GraphQL UUID. For more information check this

But in this example I am going to leave all the entry points available.

How to run

  1. Install dependencies: npm install

  2. Run the server npm start

  3. Go to http://localhost:3000/graphql to open GraphiQL.

graphql-hotels-example's People

Contributors

r0b1n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jimmea

graphql-hotels-example's Issues

Improvements list

TODO:

  • Describe data structure
  • Add parameters to list nodes
  • Add mutations
  • Add more examples

Add Relay client part

To have more complete example we need to have client implemented on Relay. And maybe on other GraphQL client libraries.

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.