Schema
In serverside, you need to build schema to declare the type of our GraphQL:
var { buildSchema } = require("graphql");
var schema = buildSchema(`
type Query {
users: [User]
findAllUserByUsername(username: String): [User]
username: [String]
}
type Mutation {
addUser(user: UserInput): User
}
input UserInput {
username: String
password: String
}
type User {
username: String
password: String
friends: [Friend]
}
type Friend {
name: String
}
`);
Note: to use something as an argument, we need to have Input type, declaring as following:
input InputType {
...
}