Skip to content

Instantly share code, notes, and snippets.

@jonlundy
Last active July 20, 2018 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonlundy/1e18a67ed1ccab2edbb7c69a970182cb to your computer and use it in GitHub Desktop.
Save jonlundy/1e18a67ed1ccab2edbb7c69a970182cb to your computer and use it in GitHub Desktop.
mutation resolvers
type Resolvers interface {
CollectionOps_Section(ctx context.Context, obj *CollectionOps, id string) (*SectionOps, error)
CollectionOps_addSection(ctx context.Context, obj *CollectionOps, name string) (*Section, error)
CollectionOps_removeSection(ctx context.Context, obj *CollectionOps, id string) (*bool, error)
Mutation_Collection(ctx context.Context, id string) (*CollectionOps, error)
Query_Collection(ctx context.Context, id string) (*Collection, error)
SectionOps_addTag(ctx context.Context, obj *SectionOps, value string) (*Tag, error)
SectionOps_removeTag(ctx context.Context, obj *SectionOps, value string) (*bool, error)
}
type ResolverRoot interface {
CollectionOps() CollectionOpsResolver
Mutation() MutationResolver
Query() QueryResolver
SectionOps() SectionOpsResolver
}
type CollectionOpsResolver interface {
Section(ctx context.Context, obj *CollectionOps, id string) (*SectionOps, error)
AddSection(ctx context.Context, obj *CollectionOps, name string) (*Section, error)
RemoveSection(ctx context.Context, obj *CollectionOps, id string) (*bool, error)
}
type MutationResolver interface {
Collection(ctx context.Context, id string) (*CollectionOps, error)
}
type QueryResolver interface {
Collection(ctx context.Context, id string) (*Collection, error)
}
type SectionOpsResolver interface {
AddTag(ctx context.Context, obj *SectionOps, value string) (*Tag, error)
RemoveTag(ctx context.Context, obj *SectionOps, value string) (*bool, error)
}
models:
CollectionOps:
model: mutate.CollectionOps
fields:
Section:
resolver: true # force a resolver to be generated
addSection:
resolver: true
removeSection:
resolver: true
SectionOps:
model: mutate.SectionOps
fields:
addTag:
resolver: true
removeTag:
resolver: true
package mutate
type CollectionOps struct {
ID string
}
type SectionOps struct {
ID string
}
type Tag {
value: String!
}
type Section {
id: ID!
name: String!
tags: [Tag!]!
tag(value: String!): Tag
}
type Collection {
id: ID!
sections: [Section!]!
section(id: ID!): Section!
}
type Query {
Collection(id: ID!): Collection
}
type SectionOps {
addTag(value: String!): Tag
removeTag(value: String!): Boolean
}
type CollectionOps {
Section(id: ID!): SectionOps
addSection(name: String!): Section
removeSection(id: ID!): Boolean
}
type Mutation {
Collection(id: ID!): CollectionOps
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment