GraphQL

для самых маленьких

GraphQL — A Query Language for APIs

type Project {
  name: String
  tagline: String
  contributors: [User]
}
{
  project(name: "GraphQL") {
    tagline
  }
}
{
  "project": {
    "tagline": "A query language for APIs"
  }
}

Зачем?

Есть же REST

{
    "name": "Mary",
    "posts": [
        { "title": "Learn GraphQL today" }
    ],
    "followers": [
        { name: "John" },
        { name: "Alice" },
        { name: "Sarah" },
    ]
}

Так давайте наколбасим DTOшки и не будем париться

class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Follower
{
    public string Name { get; set; }
}
class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User2
{
    public string Name { get; set; }
    public Post2[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Post2
{
    public string Title { get; set; }
    public string Content { get; set; }
}

class Follower
{
    public string Name { get; set; }
}
class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User2
{
    public string Name { get; set; }
    public Post2[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User3
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower2[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Post2
{
    public string Title { get; set; }
    public string Content { get; set; }
}

class Follower
{
    public string Name { get; set; }
}

class Follower2
{
    public string Name { get; set; }
    public string Birthday { get; set; }
}
class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User2
{
    public string Name { get; set; }
    public Post2[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User3
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower2[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Post2
{
    public string Title { get; set; }
    public string Content { get; set; }
}

class Follower
{
    public string Name { get; set; }
}

class Follower2
{
    public string Name { get; set; }
    public string Birthday { get; set; }
}

class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User2
{
    public string Name { get; set; }
    public Post2[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User3
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower2[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Post2
{
    public string Title { get; set; }
    public string Content { get; set; }
}

class Follower
{
    public string Name { get; set; }
}

class Follower2
{
    public string Name { get; set; }
    public string Birthday { get; set; }
}

class User
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User2
{
    public string Name { get; set; }
    public Post2[] Posts { get; set; }
    public Follower[] Followers { get; set; }
}

class User3
{
    public string Name { get; set; }
    public Post[] Posts { get; set; }
    public Follower2[] Followers { get; set; }
}

class Post
{
    public string Title { get; set; }
}

class Post2
{
    public string Title { get; set; }
    public string Content { get; set; }
}

class Follower
{
    public string Name { get; set; }
}

class Follower2
{
    public string Name { get; set; }
    public string Birthday { get; set; }
}

GraphQL

By Dmitriy Chuvichkin