graphql-hotels-example

GraphQL server example. Country/City/Hotel structure.

  • 所有者: r0b1n/graphql-hotels-example
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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.

主要指標

概覽
名稱與所有者r0b1n/graphql-hotels-example
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2016-01-23 20:42:51
推送於2016-08-08 23:54:53
最后一次提交2016-08-09 02:54:53
發布數0
用户参与
星數7
關注者數2
派生數1
提交數14
已啟用問題?
問題數2
打開的問題數2
拉請求數0
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?