Giter Site home page Giter Site logo

all-the-databases's Introduction

All the Databases

A GraphQL server tutorial combining 5 data sources:

https://www.compose.com/articles/use-all-the-databases-part-1/

To follow along, check out the empty-resolvers branch.

Code written in the tutorial can be found in:

There's also database, ORM, and seeding code in data/connectors.js.

Browse data

Here's the deployed version of this server:

all-the-databases.graphql.guide/graphiql

Now try out a query

Run locally

Get the code:

git clone [email protected]:GraphQLGuide/all-the-databases.git
cd all-the-databases
npm install

Get the databases:

brew install redis
brew install elasticsearch
brew install mongodb

Run one command per terminal tab:

mongod
redis-server /usr/local/etc/redis.conf
elasticsearch

Then in the all-the-databases/ directory, run the GraphQL server:

npm run dev

Then open:

localhost:8080/graphiql

Then query:

Query

GraphiQL screenshot

When you paste this on the left side of the GraphiQL page:

{
  user(id: 1) {
    firstName
    lastName
    photo
    mentions {
      ...TweetDetails
    }
  }      
  publicFeed {
    ...TweetDetails
  }
  cityFeed {
    ...TweetDetails
  }
}

fragment TweetDetails on Tweet {
  text
  author {
    firstName
    lastName
    photo
  }      
  city
  views
  created
}

and hit the play button (or cmd-return), then you should get something like this on the right:

{
  "data": {
    "user": {
      "firstName": "Maurine",
      "lastName": "Rau",
      "photo": "http://placekitten.com/200/139",
      "mentions": [
        {
          "text": "Maurine Rau Eligendi in deserunt.",
          "author": {
            "firstName": "Maurine",
            "lastName": "Rau",
            "photo": "http://placekitten.com/200/139"
          },
          "city": "San Francisco",
          "views": 82,
          "created": 1481757217713
        }
      ]
    },
    "publicFeed": [
      {
        "text": "Corporis qui impedit cupiditate rerum magnam nisi velit aliquam.",
        "author": {
          "firstName": "Tia",
          "lastName": "Berge",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "New York",
        "views": 91,
        "created": 1481757215183
      },
      {
        "text": "Aut numquam aut dolorem.",
        "author": {
          "firstName": "Soledad",
          "lastName": "White",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "New York",
        "views": 69,
        "created": 1481757216183
      },
      {
        "text": "Consequatur voluptates eaque voluptatem neque assumenda omnis.",
        "author": {
          "firstName": "Arlo",
          "lastName": "Kertzmann",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "New York",
        "views": 51,
        "created": 1481757217182
      }
    ],
    "cityFeed": [
      {
        "text": "Edmond Jones Harum ullam pariatur quos est quod.",
        "author": {
          "firstName": "Edmond",
          "lastName": "Jones",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "Mountain View",
        "views": 69,
        "created": 1481757216723
      },
      {
        "text": "Katlyn Reichert Quos sequi molestiae beatae.",
        "author": {
          "firstName": "Katlyn",
          "lastName": "Reichert",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "Mountain View",
        "views": 55,
        "created": 1481757214738
      },
      {
        "text": "Jayde Conn Occaecati rerum neque et.",
        "author": {
          "firstName": "Jayde",
          "lastName": "Conn",
          "photo": "http://placekitten.com/200/139"
        },
        "city": "Mountain View",
        "views": 85,
        "created": 1481757209779
      }
    ]
  }
}

all-the-databases's People

Contributors

helfer avatar lorensr 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.