Evgenii Shkodin
Front-end developer @ Evil Martians
Evgenii Shkodin
Front-end developer @ Evil Martians
Front-end
Back-end
Facebook mobile, 2011
Facebook native mobile, 2012
RESTful API
FQL
GraphQL for internal use, 2012
Public release of GraphQL specification, July 2015
Present day
GET /photos?top=3
{
description
src
img_src
comments
likes
}
GET /friends?top=3
{
name
url
avatar_url
city
job_title
job_company
}
GET /user/:id/main_view
{
name
avatar_url
bio
photos(3) {
src
}
friends(3) {
name
avatar_url
}
}
RESTful API and AdHoc requests
RESTful API and AdHoc requests
RESTful API and AdHoc requests
RESTful API and AdHoc requests
RESTful API and AdHoc requests
Objects
Properties
Relations
What is GraphQL?
What is GraphQL?
{
me {
name
}
}
{
"me": {
"name": "Evgenii Shkodin"
}
}
Basic concepts
Query
Mutation
Subscription
Basic concepts
query GET_MAIN_DATA {
me {
}
}
name
bio
avatarLg: avatar_url(size: 168)
avatarSm: avatar_url(size: 40)
socials {
url
}
photos(limit: 3) {
src
}
friends(limit: 3) {
name
avatar_url(size: 100)
}
Query
Mutation
Subscription
Basic concepts
mutation CREATE_POST($value: String!) {
createPost(value: $value) {
}
}
author {
name
avatar_url(size: 40)
}
body
id
date
...
Basic concepts
Query
Mutation
Subscription
subscription FEED_UPDATES {
postAdded {
}
}
author {
name
avatar_url(size: 40)
}
body
id
date
...
Basic concepts
query getUser($withFriends: Boolean) {
me {
name
friends @include(if: $withFriends) {
name
}
}
}
schema: {
query: Query
mutation: Mutation
subscription: Subscription
}
Query
Mutation
Subscription
Basic concepts
Basic concepts
Type checking
type Query {
}
me: User
user(id: ID!): User
type Mutation {
}
type Subscription {
}
createPost(input: PostInput!): Post!
editPost(id: ID!, input: PostInput!): Post!
deletePost(id: ID!): ID!
postAdded: Post!
Type checking
type User {
id: ID!
name String
balance: Float!
friends(limit: Int! = 10): [User!]
friends_count: Int
bio: String
isPremium: Boolean!
}
Query: {
user(obj, args, context, info) {
return context.db.loadUserByID(args.id)
}
}
User: {
name(obj, args, context, info) {
return obj.name
}
}
cute animals gif therapy
ask a GraphQL schema for information about what queries it supports
An in-browser IDE for exploring GraphQL.
(demo)
Command line tool for common GraphQL development workflows
(demo)
Command | Description |
---|---|
graphql create [directory] | Bootstrap a new GraphQL project |
graphql get-schema | Download schema from endpoint |
graphql schema-status | Show source & timestamp of local schema |
graphql query <file> | Run query/mutation |
graphql diff | Show a diff between two schemas |
Introspection 💜 IDE
(demo)
GraphQL extension for VS code
GraphQL extension for VS code
GraphQL extension for VS code
GraphQL extension for VS code
Mock or extend your GraphQL API with faked data. No coding required.
(demo)
https://github.com/APIs-guru/graphql-faker
Client
Server
Engine
Apollo Boost is a zero-config way to start using Apollo Client
https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost
npm install apollo-boost graphql graphql-tag
import ApolloClient from "apollo-boost";
import gql from "graphql-tag";
const client = new ApolloClient({
uri: "/graphql"
});
client
.query({
query: gql`
{
character(id: "1") {
name
}
}
`
})
.then(result => console.log(result));
Generate TypeScript (and Flow) type interfaces from GraphQL types and query definitions.
(demo)
https://github.com/avantcredit/gql2ts
load relevant data first
(demo)
https://github.com/avantcredit/gql2ts
query GET_FEED($page: Int!) {
me {
feed(page: $page) {
}
}
}
author {
name
avatar_url(size: 40)
}
body
...
date
id
comments @defer {
author {
name
avatarUrl(size: 40)
}
text
likes
}
Talks
Articles