From 1d8e14b4dd7dd5e40ac13c7c6e0bbdaab6a23c6f Mon Sep 17 00:00:00 2001 From: Roland Szoke Date: Fri, 20 Sep 2019 16:28:41 +0200 Subject: [PATCH] Task_1_Done --- src/gqlSchema.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/gqlSchema.js b/src/gqlSchema.js index 31c7b1c..8ed7899 100644 --- a/src/gqlSchema.js +++ b/src/gqlSchema.js @@ -3,7 +3,6 @@ const { buildSchema } = require('graphql'); const { getHello, resolveQuery } = require('./fetcher'); -// TODO: TASK 1. Add posts query const schema = buildSchema(` enum OrderDirection { asc @@ -39,15 +38,45 @@ const schema = buildSchema(` edges: [UserEdge] } + enum PostArgField { + id + title + description + content + author + timestamp + } + input PostFieldOrder { + field: PostArgField + direction: OrderDirection + } + type Post { + id: ID + title: String + description: String + content: String + author: String + timestamp: String + } + type PostEdge { + node: Post + } + type PostConnection { + pageInfo: PageInfo + edges: [PostEdge] + } + type Query { hello: String - users: UserConnection + users(limit: Int, offset: Int, order: UserFieldOrder): UserConnection + posts(limit: Int, offset: Int, order: PostFieldOrder): PostConnection } `); const rootValue = { hello: () => getHello(), users: (args) => resolveQuery({ table: 'users', args }), + posts: (args) => resolveQuery({ table: 'posts', args }), }; module.exports = {