"http://tech.eshaiju.in/blog/2017/05/ "body": null, "votes": 100, "published_at": "11 Jul 2017 00 00 AM", "auther_name": "Shaiju E", "created_at": "2017-07-11 12:57:20 UTC", "updated_at": "2017-07-11 13:15:50 UTC" } "post": { "id": 1, "title": "A GraphQL Server Implementation", "url": "http://tech.eshaiju.in/blog/2017/05/06/a-graphql-server-implementation-ruby-on-rails/" } What I get What I care about Over-fetching of data
is a new API standard that provides an alternative to REST Declarative data fetching - The client specifies what data shapes, and the server returns that data in exact same shape. GraphQL server only exposes a single endpoint and responds with precisely the data a client asked for GraphQL
1}) { post{ id title comments{ body user{ name } } } } } Mutations are used to change your data Mutations are the equivalent to the POST, PUT, PATCH and DELETE in HTTP/REST. Mutation
field :id, types.Int field :title, types.String do resolve -> (post, args, ctx) { post.title } end field :body, types.String field :url, types.String field :votes, types.Int field :published_at, types.String do resolve -> (post, args, ctx) { post.published_at.strftime('%d %b %Y %H %M %p') } deprecation_reason 'This field is deprecated' end field :comments, types[CommentType] field :author, UserType end Implementation - Type System
data that's explicitly requested New capabilities can be added via new types and new fields on those types without creating a breaking change. Deprecate older fields