Giter Site home page Giter Site logo

apollo-server-fly1's Introduction

Apollo Server on Fly.io

This is an example showing how to use the beta version of ApolloServer 2.0 with Fly.io. To build your schema, edit the index.js file to match the shape of the data your application needs and connect it to backend REST endpoints. Then run npm run build to create a bundle that you can upload to fly using "fly deploy"

Really early build, you can replace the fetch links within index.js with your own REST API endpoints.

Installation

npm install

Building

npm run build

Testing locally

Step 1: create an app on Fly

fly create app graphql-translator

Step 2: start the app locally to test

fly start

Step 3: test it by accessing

Querying just the ID of the car for a particular plateNumber https://localhost:3000/?query={car(plateNumber:"APP756IE"){id:id}}

Querying just the colors of all the cars within our /cars api https://localhost:3000/?query={cars{id:id}}

Step 4: deploy app to prod

fly deploy

Next Step to figure out how to batch REST API results from multiple api endpoints and then batch them into a single graphql response.

Production App

Benefits of having GraphQL vs REST API : Byte Savings and security

Use-Case 1: I am interested in finding all the plateNumbers in my system and pick a particular plate number and check what model is the car.

Querying all the plateNumbers in the REST API backend

via GraphQL https://apollo-server-demo1.edgeapp.net/?query={cars{plateNumber:plateNumber}} Response Size: 176B

via REST API https://mvrp.herokuapp.com/api/cars Response Size: 1.2KB

Querying the model number for a particular plate

via GraphQL Querying just the model of the car for a particular plateNumber https://apollo-server-demo1.edgeapp.net/?query={car(plateNumber:%22APP756IE%22){model:model}} Response Size: 173B

via REST API https://mvrp.herokuapp.com/api/car?plateNumber=APP756IE Response Size: 421B

apollo-server-fly1's People

Contributors

akhiljay avatar

Stargazers

 avatar

Watchers

James Cloos avatar

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.