Skip to content

Using GraphQL to store, retrieve and manipulate books and authors example data.

Notifications You must be signed in to change notification settings

mostafaaminflakes/GraphQL-Client-Server-Sample-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

GraphQL-Client-Server-Sample-Code

This example is using GraphQL to store, retrieve and manipulate books and authors data.

The front end is using Reactjs and Apollo which will be able to make queries to the graphql server and retrieve data back into the browser.

The back end is using GraphQL server on Nodejs using Express to describe how the graph looks (types of data on the graph, and the relations between those types), and setup different entry points into the graph. This is hooked up with two different types of data storage:

  1. Flat javascript local array.
  2. Mongodb online database instance.

Tip 1: Use Graphiql tool from the browser to simulate making queries from the front end to the GraphQL server.

Tip 2: You can change the data source for the app by editing the variable [schema] in the file [./server/app.js] and use either local or remote data source, default is local.

Downloading GraphQL-Client-Server-Sample-Code

You can install GraphQL-Client-Server-Sample-Code as follows:

cd folder/to/clone-into/
git clone https://github.com/mostafaaminflakes/GraphQL-Client-Server-Sample-Code.git

Dependencies

Make sure to install the following dependencies:

Server

  • express
  • graphql
  • express-graphql
  • lodash
  • mongoose

Client

  • react
  • apollo-boost
  • react-apollo
  • graphql
  • lodash

Tip: You may run [npm install] from inside both client and server folders to install the required dependencies.

Usage

You need two instances of cmd:

1. To run the server:

   cd path/to/server/folder/
   node app

Then open your browser at [localhost:4000/graphql]

2. To run the client:

   cd path/to/client/folder/
   npm start

Then open your browser at [localhost:3000]

About

Using GraphQL to store, retrieve and manipulate books and authors example data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published