GET http://api.com/products/281
POST http://api.com/products/
PUT http://api.com/products/281
DELETE http://api.com/products/281
Order GetOrderById(int orderId);
Order GetOrderByName(string name);
Order GetOrderWithProductDetails(int orderId);
Order GetOrderWithCustomerInfo(int orderId);
Order GetOrderWithCustomerInfoByOrderName(string name);
Order GetOrderWithShippingData(int orderId);
Order GetOrderWithShippingDataAndCustomerInfo(int orderId);
{
"id": 1337,
"title": "Horse steroids - guide for athletes",
"author": {
"firstName": "Andy",
"lastName": "Greenberg"
},
"created": "2015-05-22T14:56:29.000Z",
"comments": [
{
"author": {
"firstName": "Sam",
"lastName": "Gonagal"
},
"created": "2015-05-22T14:56:34.000Z"
},
{
"author": {
"firstName": "Christ",
"lastName": "McSwagger"
},
"created": "2016-05-22T14:56:34.000Z"
}
]
}
query {
article(id: 1337) {
id
title
author {
...fullName
}
created
comments {
author {
...fullName
}
created
}
}
}
fragment fullName on User {
firstName
lastName
}
Request
Response
CRUD? Not anymore.
query RepositoryWatchers {
repository(owner:"fsprojects", name:"Paket") {
id
name
watchers(first:20) {
edges {
node {
... on User {
login
}
}
}
}
}
}
mutation Comment($data:AddCommentInput!) {
addComment(input:$data) {
clientMutationId
commentEdge {
node {
... on IssueComment {
createdAt
}
}
}
}
}
Read only
Read-write
type Query {
animal(name: String!): Animal @deprecated(reason: "lol")
cat(name: String!): Cat
dog(name: String!): Dog
}
interface Animal {
id: String!
name: String
}
type Dog implements Animal {
id: String!
name: String
role: Role
}
type Cat implements Animal {
id: String!
name: String
}
enum Role { Watchdog, Hunter, Pet }
query {
__schema {
types {
name
fields {
name
type {
name
}
}
}
}
}
Use GraphQL query to get metadata about GraphQL itself
1st request
2nd request
Example component
const FeedWithData = graphql(gql`
{
feed (type: TOP, limit: 5) {
repository {
owner { login }
name
}
postedBy { login }
}
}
`)(Feed);
function Feed({ data }) {
return (
<View>
<Text style={styles.title}>GitHunt</Text>
{ data.feed.map((item) =>
<View style={styles.feedItem}>
<Text style={styles.entry}>
{item.repository.owner.login}/{item.repository.name}
</Text>
<Text>Posted by {item.postedBy.login}</Text>
</View>) }
</View>
);
}
var orders = db.Customers.SelectMany(u => u.Orders);
foreach (var order in orders) {
foreach (var product in order.Products) {
DoSomething(product);
}
}
Bartosz Sypytkowski
@horusiath
b.sypytkowski@gmail.com
http://bartoszsypytkowski.com