Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Thinking in GraphQL

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for igorapa igorapa
March 30, 2016

Thinking in GraphQL

This is my first talk that happened in 7masters.
I made an overview in 7 minutes on what it is and why use GraphQL.
--
http://setemasters.imasters.com.br/

Avatar for igorapa

igorapa

March 30, 2016
Tweet

More Decks by igorapa

Other Decks in Technology

Transcript

  1. 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.
  2. { user(id: 30) { name, foo: friend(id: 2) { name

    } bar: friend(id: 13) { name, email } } } Aliases
  3. { "data": { "user": { "name": "Igor APA", "foo": {

    "name": "Foo" }, "bar": { "name": "Bar", "email": "[email protected]" } } } } Aliases
  4. 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
  5. 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;
  6. . !"" 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