dacz / apollo-bridge-link-example

demo: Develop with GraphQl on the client facing server with REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOT MAINTAINED ANYMORE

Use GraphQL with Rest API - demo

travis.ci Greenkeeper badge license

Develop with GraphQl on the client facing server with REST API.

This demo uses apollo-bridge-link library (build on top of Apollo).

I use the core functionality (apollo-bridge-link) for production code for clients and it works ok. But it's work in progress as the requirements arise and I implement them and then find a time to put them into this demo.

It is barebone, minimally styled.

The article about the demo is here

Run demo

# start wihh fresh data
cp db.json.dist db.json

# in one console - start JSON mock server
npm run rest-server

# in another console - start client
npm run dev

# ----
# if you want develop against GraphQL server before switching to Bridge
# (see below)
# run in another termina window:
npm run graphql-server

Develop as with GraphQL server

When you are developing on the client side (and especially with React Native), it's handy just to talk to GraphQL server with standard HTTP link and then switch to Bridge Link and keep all your work done.

This example contains demostrate, how to do this with sharing all the code (and only minor configuration of apollo link).

Basically in the App.js comment or uncomment which link you want to use.

If you choose Bridge, run only npm run rest-server.

If you choose HttpLink, run (in two opened teerminals npm run rest-server and in the second one npm run graphql-server).

Basically - your app will talk to GraphQL server (that uses all your resolvers, dataloaders etc.) and this server will talk to REST API server.

Parts

Data

Your data will be in db.json file (with your changes).

ToDo

  • demo handling authorization token
  • write blogpost about this example to explain little bit more (here)
  • graphql server for easier developing (using all logic, resolvers, etc., just switching apollo link)

Sponsors

LiveAndCode - passionate group of javascript developers (contact juraj@liveandcode.cz). Thanks!!

About

demo: Develop with GraphQl on the client facing server with REST API

License:MIT License


Languages

Language:JavaScript 88.8%Language:CSS 10.6%Language:HTML 0.6%