alex-wilmer / graphql-101

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

graphql-101

Install:

npm run setup

Start graphql express server:

npm run api
``

Start front end React dev server:

npm run ui


<hr />

## Why graphql?

What:

graphql is a "communication language", specified by Facebook to make client <-> server interaction more expressive and reliable vs the existing standard: REST.

Why:

The "communication language" of REST is simple by design--it consists of URLs and HTTP methods. Modern applications are more complex than their predecessors and benefit from a more feature rich "communication language". graphql adds field types, relationships, errors, deprecation warnings, schema introspection and more!

How:

Similar to REST, graphql is only a "spec" which explains the semantics of the language and a description of how a runtime environment should work. It is not an actual module, library or framework. However, there are implementations of the graphql spec in every major language.

The three main components of a working graphql implementation are:

1) A schema:

```js
type Query {
  hello: String
}
  1. A query:
query { hello }
  1. A resolution map:
{ hello: () => 'Hello world!' }

The query is validated against the schema, then if valid, traverses the resolution map to build the response.

graphql(schema, query, resolutionMap).then(result => console.log(result))

> { data: { hello: 'Hello world!' } }

Resources:

Clients:

About


Languages

Language:JavaScript 71.6%Language:HTML 28.4%