Devacron.com

GraphQL Intro

GraphQL Logo

Spend 30 minutes learning how to adapt your existing ORM, SOA, or REST API to GraphQL so that you can begin to use GraphQL-based technologies like Relay.

What is GraphQL?

A GraphQL query is a string interpreted by a server that returns data in a specified format. Here is an example query:

{
  user(id: 3500401) {
    id,
    name,
    isViewerFriend,
    profilePicture(size: 50)  {
      uri,
      width,
      height
    }
  }
}

(Note: this syntax is slightly different from previous GraphQL examples. We’ve recently been making improvements to the language.)

And here is the response to that query.

{
  "user" : {
    "id": 3500401,
    "name": "Jing Chen",
    "isViewerFriend": true,
    "profilePicture": {
      "uri": "http://someurl.cdn/pic.jpg",
      "width": 50,
      "height": 50
    }
  }
}

We will dig into the syntax and semantics of GraphQL in a later post, but even a simple example shows many of its design principles:

Exit mobile version