Last active
September 23, 2018 17:20
-
-
Save Mefistophell/a8258da0b51f3b110db35d530d948c4d to your computer and use it in GitHub Desktop.
apollo-graphql-api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { gql } = require('apollo-server-koa') | |
const UserType = require('./types/user') | |
const PostType = require('./types/post') | |
const RootQuery = gql` | |
type Query { | |
getUser(id: Int!): User | |
getPostsByUserId(user_id: Int!): [Post!] | |
} | |
`; | |
const RootMutation = ` | |
type Mutation { | |
addUser(username: String!, password: String!, fullname: String, email: String, phone: String): String | |
addPost(user_id: Int!, title: String!, content: String!): String | |
updatePost(id: Int!, title: String, content: String): Boolean | |
} | |
`; | |
const SchemaDefinition = ` | |
schema { | |
query: Query | |
mutation: Mutation | |
} | |
`; | |
module.exports = [ | |
SchemaDefinition, RootQuery, RootMutation, UserType, PostType | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = `type Post { | |
title: String | |
content: String | |
}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = `type User { | |
username: String | |
fullName: String | |
phone: String | |
email: String | |
}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment