Skip to content

Commit

Permalink
Task_1_Done
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandszoke committed Sep 20, 2019
1 parent 96105fe commit 1d8e14b
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/gqlSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 1d8e14b

Please sign in to comment.