Scaffold GraphQL server

This commit is contained in:
David Stotijn
2019-12-01 14:47:25 +01:00
parent 1164837247
commit ef96a69baa
8 changed files with 2986 additions and 4 deletions

2829
pkg/api/generated.go Normal file

File diff suppressed because it is too large Load Diff

20
pkg/api/models_gen.go Normal file
View File

@ -0,0 +1,20 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package api
type NewTodo struct {
Text string `json:"text"`
UserID string `json:"userId"`
}
type Todo struct {
ID string `json:"id"`
Text string `json:"text"`
Done bool `json:"done"`
User *User `json:"user"`
}
type User struct {
ID string `json:"id"`
Name string `json:"name"`
}

26
pkg/api/resolver.go Normal file
View File

@ -0,0 +1,26 @@
package api
import (
"context"
) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
type Resolver struct{}
func (r *Resolver) Mutation() MutationResolver {
return &mutationResolver{r}
}
func (r *Resolver) Query() QueryResolver {
return &queryResolver{r}
}
type mutationResolver struct{ *Resolver }
func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) {
panic("not implemented")
}
type queryResolver struct{ *Resolver }
func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) {
panic("not implemented")
}

28
pkg/api/schema.graphql Normal file
View File

@ -0,0 +1,28 @@
# GraphQL schema example
#
# https://gqlgen.com/getting-started/
type Todo {
id: ID!
text: String!
done: Boolean!
user: User!
}
type User {
id: ID!
name: String!
}
type Query {
todos: [Todo!]!
}
input NewTodo {
text: String!
userId: String!
}
type Mutation {
createTodo(input: NewTodo!): Todo!
}