gqlgenのschemaとresolverを分割する

extend type Queryextend type Mutationにする。

type Author {
  id: ID!
  name: String!
  email: String!
  age: Int
  books: [Book]
}

extend type Query {
  author(id: ID!): Author
  allAuthor: [Author]
}

extend type Mutation {
  createAuthor: Author
}
package graph

// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.45

import (
	"context"
	"fmt"

	"github.com/38elements/gql-example/graph/model"
)

// CreateAuthor is the resolver for the createAuthor field.
func (r *mutationResolver) CreateAuthor(ctx context.Context) (*model.Author, error) {
	panic(fmt.Errorf("not implemented: CreateAuthor - createAuthor"))
}

// Author is the resolver for the author field.
func (r *queryResolver) Author(ctx context.Context, id string) (*model.Author, error) {
	panic(fmt.Errorf("not implemented: Author - author"))
}

// AllAuthor is the resolver for the allAuthor field.
func (r *queryResolver) AllAuthor(ctx context.Context) ([]*model.Author, error) {
	panic(fmt.Errorf("not implemented: AllAuthor - allAuthor"))
}

// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }

// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
type Book {
  id: ID!
  title: String!
  content: String!
  author: Author!
}

extend type Query {
  book(id: ID!): Book
  allBooks: [Book]
}

extend type Mutation {
  createBook: Book
}
package graph

// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.45

import (
	"context"
	"fmt"

	"github.com/38elements/gql-example/graph/model"
)

// CreateBook is the resolver for the createBook field.
func (r *mutationResolver) CreateBook(ctx context.Context) (*model.Book, error) {
	panic(fmt.Errorf("not implemented: CreateBook - createBook"))
}

// Book is the resolver for the book field.
func (r *queryResolver) Book(ctx context.Context, id string) (*model.Book, error) {
	panic(fmt.Errorf("not implemented: Book - book"))
}

// AllBooks is the resolver for the allBooks field.
func (r *queryResolver) AllBooks(ctx context.Context) ([]*model.Book, error) {
	panic(fmt.Errorf("not implemented: AllBooks - allBooks"))
}