Slide 1

Slide 1 text

GraphQL http://graphql.org/ Thinking in

Slide 2

Slide 2 text

@igorapa

Slide 3

Slide 3 text

https://www.loggi.com

Slide 4

Slide 4 text

rgr = roger

Slide 5

Slide 5 text

What is GraphQL? GraphQL is a data query language and runtime designed and used at Facebook to request and deliver data to mobile and web apps since 2012.

Slide 6

Slide 6 text

https://cldup.com/ysnmIMhqRU.png

Slide 7

Slide 7 text

https://github.com/graphql/swapi-graphql

Slide 8

Slide 8 text

https://github.com/graphql/swapi-graphql

Slide 9

Slide 9 text

Why GraphQL? - Maintainability - Single-round trip - No over-fetching (no more no less) -

Slide 10

Slide 10 text

{ user(id: 30) { name, foo: friend(id: 2) { name } bar: friend(id: 13) { name, email } } } Aliases

Slide 11

Slide 11 text

{ "data": { "user": { "name": "Igor APA", "foo": { "name": "Foo" }, "bar": { "name": "Bar", "email": "[email protected]" } } } } Aliases

Slide 12

Slide 12 text

import { GraphQLID, GraphQLInt, GraphQLList, GraphQLSchema, GraphQLString, GraphQLNonNull, GraphQLObjectType, } from 'graphql'; Schema.js

Slide 13

Slide 13 text

let Schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: () => ({ store: { type: storeType, resolve: () => store } }) }), mutation: new GraphQLObjectType({ name: 'Mutation', fields: () => ({ createData: createDataMutation }) }) }); export default Schema; Schema.js

Slide 14

Slide 14 text

server.js app.use('/graphql', GraphQLHTTP({ schema, graphiql: true }));

Slide 15

Slide 15 text

Schema.js import {post} from 'jquery'; import ServerActions from './actions/ServerActions'; let API = { fetchDatas() { post('/graphql', { query: `{ value { _id, title, url } }` }).done(resp => { ServerActions.receiveDatas(resp.data.value); }); } }; export default API;

Slide 16

Slide 16 text

. !"" data # %"" schema.js !"" js # !"" API.js # !"" AppDispatcher.js # !"" Constants.js # !"" actions # # %"" ServerActions.js # !"" app.js # !"" components # # !"" Item.js # # %"" Main.js # %"" store # %"" DataStore.js !"" package.json !"" public !"" server.js %"" webpack.config.js Tree

Slide 17

Slide 17 text

@igorapa Thank you!