[JAVA-14663] Update Graphql code for Boot 2.7.x changes and move to new module (#12729)
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "bae0e3d0-2b86-46aa-b6df-523497a2296a",
|
||||
"name": "GraphQL collection",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "mutations",
|
||||
"item": [
|
||||
{
|
||||
"name": "createPost",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "mutation createPost ($title: String!, $text: String!, $category: String, $authorId: String!) {\n createPost (title: $title, text: $text, category: $category, authorId: $authorId) {\n id\n title\n text\n category\n }\n}",
|
||||
"variables": "{\n \"title\": \"new post\",\n \"text\": \"new post text\",\n \"category\": \"category\",\n \"authorId\": \"Author0\"\n}"
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:8080/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "8080",
|
||||
"path": [
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "queries",
|
||||
"item": [
|
||||
{
|
||||
"name": "get recent posts",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}",
|
||||
"variables": ""
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:8080/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "8080",
|
||||
"path": [
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "recentPosts - variables",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}",
|
||||
"variables": "{\n \"count\": 5,\n \"offset\": 0\n}"
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:8080/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "8080",
|
||||
"path": [
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "url",
|
||||
"value": "",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
29
spring-boot-modules/spring-boot-graphql/README.md
Normal file
29
spring-boot-modules/spring-boot-graphql/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
## Spring Boot Graphql
|
||||
|
||||
This module contains articles about Spring Boot Graphql
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql)
|
||||
- [Expose GraphQL Field with Different Name](https://www.baeldung.com/graphql-field-name)
|
||||
|
||||
### GraphQL sample queries
|
||||
|
||||
Query
|
||||
```shell script
|
||||
curl \
|
||||
--request POST 'localhost:8080/graphql' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{"query":"query {\n recentPosts(count: 2, offset: 0) {\n id\n title\n author {\n id\n posts {\n id\n }\n }\n }\n}"}'
|
||||
```
|
||||
|
||||
Mutation
|
||||
```shell script
|
||||
curl \
|
||||
--request POST 'localhost:8080/graphql' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{"query":"mutation {\n createPost(title: \"New Title\", authorId: \"Author2\", text: \"New Text\") {\n id\n category\n author {\n id\n name\n }\n }\n}"}'
|
||||
```
|
||||
41
spring-boot-modules/spring-boot-graphql/pom.xml
Normal file
41
spring-boot-modules/spring-boot-graphql/pom.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-graphql</artifactId>
|
||||
<name>spring-boot-graphql</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring-boot-modules</groupId>
|
||||
<artifactId>spring-boot-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-graphql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.graphql</groupId>
|
||||
<artifactId>spring-graphql-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Author {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String thumbnail;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import org.springframework.graphql.data.method.annotation.SchemaMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AuthorController {
|
||||
|
||||
private final PostDao postDao;
|
||||
|
||||
public AuthorController(PostDao postDao) {
|
||||
this.postDao = postDao;
|
||||
}
|
||||
|
||||
@SchemaMapping
|
||||
public List<Post> posts(Author author) {
|
||||
return postDao.getAuthorPosts(author.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AuthorDao {
|
||||
private final List<Author> authors;
|
||||
|
||||
public AuthorDao(List<Author> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public Author getAuthor(String id) {
|
||||
return authors.stream()
|
||||
.filter(author -> id.equals(author.getId()))
|
||||
.findFirst()
|
||||
.orElseThrow(RuntimeException::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableAutoConfiguration(exclude = {SecurityAutoConfiguration.class})
|
||||
public class GraphqlApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GraphqlApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class GraphqlConfiguration {
|
||||
|
||||
@Bean
|
||||
public PostDao postDao() {
|
||||
List<Post> posts = new ArrayList<>();
|
||||
for (int postId = 0; postId < 10; ++postId) {
|
||||
for (int authorId = 0; authorId < 10; ++authorId) {
|
||||
Post post = new Post();
|
||||
post.setId("Post" + authorId + postId);
|
||||
post.setTitle("Post " + authorId + ":" + postId);
|
||||
post.setCategory("Post category");
|
||||
post.setText("Post " + postId + " + by author " + authorId);
|
||||
post.setAuthorId("Author" + authorId);
|
||||
posts.add(post);
|
||||
}
|
||||
}
|
||||
return new PostDao(posts);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorDao authorDao() {
|
||||
List<Author> authors = new ArrayList<>();
|
||||
for (int authorId = 0; authorId < 10; ++authorId) {
|
||||
Author author = new Author();
|
||||
author.setId("Author" + authorId);
|
||||
author.setName("Author " + authorId);
|
||||
author.setThumbnail("http://example.com/authors/" + authorId);
|
||||
authors.add(author);
|
||||
}
|
||||
return new AuthorDao(authors);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Post {
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
private String text;
|
||||
private String category;
|
||||
private String authorId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import org.springframework.graphql.data.method.annotation.Argument;
|
||||
import org.springframework.graphql.data.method.annotation.MutationMapping;
|
||||
import org.springframework.graphql.data.method.annotation.QueryMapping;
|
||||
import org.springframework.graphql.data.method.annotation.SchemaMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Controller
|
||||
public class PostController {
|
||||
|
||||
private final PostDao postDao;
|
||||
private final AuthorDao authorDao;
|
||||
|
||||
public PostController(PostDao postDao, AuthorDao authorDao) {
|
||||
this.postDao = postDao;
|
||||
this.authorDao = authorDao;
|
||||
}
|
||||
|
||||
@QueryMapping
|
||||
public List<Post> recentPosts(@Argument int count, @Argument int offset) {
|
||||
return postDao.getRecentPosts(count, offset);
|
||||
}
|
||||
|
||||
@SchemaMapping
|
||||
public Author author(Post post) {
|
||||
return authorDao.getAuthor(post.getAuthorId());
|
||||
}
|
||||
|
||||
@SchemaMapping(typeName="Post", field="first_author")
|
||||
public Author getFirstAuthor(Post post) {
|
||||
return authorDao.getAuthor(post.getAuthorId());
|
||||
}
|
||||
|
||||
@MutationMapping
|
||||
public Post createPost(@Argument String title, @Argument String text,
|
||||
@Argument String category, @Argument String authorId) {
|
||||
Post post = new Post();
|
||||
post.setId(UUID.randomUUID().toString());
|
||||
post.setTitle(title);
|
||||
post.setText(text);
|
||||
post.setCategory(category);
|
||||
post.setAuthorId(authorId);
|
||||
postDao.savePost(post);
|
||||
|
||||
return post;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PostDao {
|
||||
|
||||
private final List<Post> posts;
|
||||
|
||||
public PostDao(List<Post> posts) {
|
||||
this.posts = posts;
|
||||
}
|
||||
|
||||
public List<Post> getRecentPosts(int count, int offset) {
|
||||
return posts.stream()
|
||||
.skip(offset)
|
||||
.limit(count)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Post> getAuthorPosts(String author) {
|
||||
return posts.stream()
|
||||
.filter(post -> author.equals(post.getAuthorId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void savePost(Post post) {
|
||||
posts.add(post);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
spring:
|
||||
graphql:
|
||||
graphiql:
|
||||
enabled: true
|
||||
@@ -0,0 +1,25 @@
|
||||
type Post {
|
||||
id: ID!
|
||||
title: String!
|
||||
text: String!
|
||||
category: String
|
||||
author: Author!
|
||||
first_author: Author!
|
||||
}
|
||||
|
||||
type Author {
|
||||
id: ID!
|
||||
name: String!
|
||||
thumbnail: String
|
||||
posts: [Post]!
|
||||
}
|
||||
|
||||
# The Root Query for the application
|
||||
type Query {
|
||||
recentPosts(count: Int, offset: Int): [Post]!
|
||||
}
|
||||
|
||||
# The Root Mutation for the application
|
||||
type Mutation {
|
||||
createPost(title: String!, text: String!, category: String, authorId: String!) : Post!
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.graphql.test.tester.GraphQlTester;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@GraphQlTest(PostController.class)
|
||||
@Import(GraphqlConfiguration.class)
|
||||
class PostControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private GraphQlTester graphQlTester;
|
||||
|
||||
@Test
|
||||
void givenPosts_whenExecuteQueryForRecentPosts_thenReturnResponse() {
|
||||
String documentName = "recent_posts";
|
||||
|
||||
graphQlTester.documentName(documentName)
|
||||
.variable("count", 2)
|
||||
.variable("offset", 0)
|
||||
.execute()
|
||||
.path("$")
|
||||
.matchesJson(expected(documentName));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenNewPostData_whenExecuteMutation_thenNewPostCreated() {
|
||||
String documentName = "create_post";
|
||||
|
||||
graphQlTester.documentName(documentName)
|
||||
.variable("title", "New Post")
|
||||
.variable("text", "New post text")
|
||||
.variable("category", "category")
|
||||
.variable("authorId", "Author0")
|
||||
.execute()
|
||||
.path("createPost.id").hasValue()
|
||||
.path("createPost.title").entity(String.class).isEqualTo("New Post")
|
||||
.path("createPost.text").entity(String.class).isEqualTo("New post text")
|
||||
.path("createPost.category").entity(String.class).isEqualTo("category");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static String expected(String fileName) {
|
||||
Path path = Paths.get("src/test/resources/graphql-test/" + fileName + "_expected_response.json");
|
||||
return new String(Files.readAllBytes(path));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.graphql;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest(classes = GraphqlApplication.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "910d9690-f629-4491-bbbd-adb30982a386",
|
||||
"name": "GraphQL collection",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "mutations",
|
||||
"item": [
|
||||
{
|
||||
"name": "createPost",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "mutation createPost ($title: String!, $text: String!, $category: String) {\n createPost (title: $title, text: $text, category: $category) {\n id\n title\n text\n category\n }\n}",
|
||||
"variables": "{\n \"title\": \"\",\n \"text\": \"\",\n \"category\": \"\"\n}"
|
||||
},
|
||||
"options": {
|
||||
"graphql": {}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:9090/springbootapp/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "9090",
|
||||
"path": [
|
||||
"springbootapp",
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"protocolProfileBehavior": {}
|
||||
},
|
||||
{
|
||||
"name": "queries",
|
||||
"item": [
|
||||
{
|
||||
"name": "get recent posts",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}",
|
||||
"variables": ""
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:9090/springbootapp/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "9090",
|
||||
"path": [
|
||||
"springbootapp",
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "recentPosts - variables",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "graphql",
|
||||
"graphql": {
|
||||
"query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}",
|
||||
"variables": "{\n \"count\": 1,\n \"offset\": 0\n}"
|
||||
},
|
||||
"options": {
|
||||
"graphql": {}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:9090/springbootapp/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "9090",
|
||||
"path": [
|
||||
"springbootapp",
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "get recent posts - raw",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/graphql",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "query {\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:9090/springbootapp/graphql",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "9090",
|
||||
"path": [
|
||||
"springbootapp",
|
||||
"graphql"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"protocolProfileBehavior": {}
|
||||
}
|
||||
],
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "b54f267b-c450-4f2d-8105-2f23bab4c922",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "00b575be-03d4-4b29-b137-733ead139638",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"id": "20a274e5-6d51-40d6-81cb-af9eb115b21b",
|
||||
"key": "url",
|
||||
"value": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"protocolProfileBehavior": {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
mutation createPost ($title: String!, $text: String!, $category: String, $authorId: String!) {
|
||||
createPost (title: $title, text: $text, category: $category, authorId: $authorId) {
|
||||
id
|
||||
title
|
||||
text
|
||||
category
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
query recentPosts ($count: Int, $offset: Int) {
|
||||
recentPosts (count: $count, offset: $offset) {
|
||||
id
|
||||
title
|
||||
text
|
||||
category
|
||||
author {
|
||||
id
|
||||
name
|
||||
thumbnail
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"data": {
|
||||
"recentPosts": [
|
||||
{
|
||||
"id": "Post00",
|
||||
"title": "Post 0:0",
|
||||
"category": "Post category",
|
||||
"text": "Post 0 + by author 0",
|
||||
"author": {
|
||||
"id": "Author0",
|
||||
"name": "Author 0",
|
||||
"thumbnail": "http://example.com/authors/0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "Post10",
|
||||
"title": "Post 1:0",
|
||||
"category": "Post category",
|
||||
"text": "Post 0 + by author 1",
|
||||
"author": {
|
||||
"id": "Author1",
|
||||
"name": "Author 1",
|
||||
"thumbnail": "http://example.com/authors/1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user