From 6f4efc2b70da87a9dc49ce079a609b9777ee63ed Mon Sep 17 00:00:00 2001 From: bigbes Date: Wed, 22 Jul 2026 18:07:22 +0300 Subject: [PATCH] feat(graph): the read-only GraphQL schema at /query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eight query fields over the service layer, no Mutation and no Subscription — the design defers mutations until the proposal state machine settles, and TestSchemaHasNoMutations stands guard on that. Access is fail-closed and gated before parse, matching web's ACL exactly, so introspection is treated as content too. A federating api.sr.ht must therefore present a token or skip us, which costs one log line. A malformed rev is reported as a GraphQL error rather than folded into null. service/ deliberately hides malformed-versus-absent from probing, but the caller here is already authenticated as the owner or its own agent, and a bare null for rev=proposals/42 is indistinguishable from an absent document — it reads as a silently dropped argument. Proposal listing declares its port but is unwired: service/ exposes no proposal read yet, and returning an empty list would tell a reviewer their queue is clear when it is merely unread. --- go.mod | 4 +- graph/api/generated.go | 8080 +++++++++++++++++++++++++++++++++++++ graph/generate.go | 18 + graph/gqlgen.yml | 30 + graph/graph_test.go | 1075 +++++ graph/model/models.go | 95 + graph/model/models_gen.go | 99 + graph/resolver.go | 106 + graph/schema.graphqls | 294 ++ graph/schema.resolvers.go | 448 ++ graph/server.go | 155 + 11 files changed, 10402 insertions(+), 2 deletions(-) create mode 100644 graph/api/generated.go create mode 100644 graph/generate.go create mode 100644 graph/gqlgen.yml create mode 100644 graph/graph_test.go create mode 100644 graph/model/models.go create mode 100644 graph/model/models_gen.go create mode 100644 graph/resolver.go create mode 100644 graph/schema.graphqls create mode 100644 graph/schema.resolvers.go create mode 100644 graph/server.go diff --git a/go.mod b/go.mod index 1ea4215b2035668cec696345659426f2e90360cd..c7f7fddc51246c1bf89bf8a271831ece4426785c 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.26.4 require ( git.sr.ht/~bitfehler/brant v0.5.1 + github.com/99designs/gqlgen v0.17.36 github.com/alexflint/go-arg v1.6.0 github.com/blevesearch/bleve/v2 v2.6.0 github.com/fernet/fernet-go v0.0.0-20211208181803-9f70042a33ee @@ -13,6 +14,7 @@ require ( github.com/modelcontextprotocol/go-sdk v1.6.1 github.com/stretchr/testify v1.11.1 github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec + github.com/vektah/gqlparser/v2 v2.5.8 github.com/yuin/goldmark v1.8.2 go.bigb.es/auxilia v0.5.0 gopkg.in/yaml.v3 v3.0.1 @@ -24,7 +26,6 @@ require ( git.sr.ht/~sircmpwn/dowork v0.0.0-20241216125407-2b00aa42322c // indirect git.sr.ht/~sircmpwn/getopt v1.0.0 // indirect git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9 // indirect - github.com/99designs/gqlgen v0.17.36 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/ProtonMail/go-crypto v1.3.0 // indirect github.com/RoaringBitmap/roaring/v2 v2.14.5 // indirect @@ -93,7 +94,6 @@ require ( github.com/segmentio/encoding v0.5.4 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/skeema/knownhosts v1.3.1 // indirect - github.com/vektah/gqlparser/v2 v2.5.8 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect go.etcd.io/bbolt v1.4.0 // indirect diff --git a/graph/api/generated.go b/graph/api/generated.go new file mode 100644 index 0000000000000000000000000000000000000000..2055114776aacb59c878f60f99c02df0a0803fe9 --- /dev/null +++ b/graph/api/generated.go @@ -0,0 +1,8080 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package api + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + "sourcecraft.dev/bigbes/sr-ht-spec/graph/model" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Project() ProjectResolver + Query() QueryResolver + Space() SpaceResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Document struct { + Blob func(childComplexity int) int + DocID func(childComplexity int) int + ID func(childComplexity int) int + Markdown func(childComplexity int) int + Owners func(childComplexity int) int + Path func(childComplexity int) int + Pinned func(childComplexity int) int + Rev func(childComplexity int) int + Section func(childComplexity int) int + Space func(childComplexity int) int + Status func(childComplexity int) int + Summary func(childComplexity int) int + Supersedes func(childComplexity int) int + Tags func(childComplexity int) int + Title func(childComplexity int) int + Type func(childComplexity int) int + } + + Project struct { + Meta func(childComplexity int) int + Name func(childComplexity int) int + Owner func(childComplexity int) int + Ref func(childComplexity int) int + Spaces func(childComplexity int) int + } + + Proposal struct { + Agent func(childComplexity int) int + AgentSession func(childComplexity int) int + Approval func(childComplexity int) int + BaseRev func(childComplexity int) int + Branch func(childComplexity int) int + Created func(childComplexity int) int + ID func(childComplexity int) int + MergedRev func(childComplexity int) int + Rationale func(childComplexity int) int + Resolved func(childComplexity int) int + Space func(childComplexity int) int + State func(childComplexity int) int + Title func(childComplexity int) int + } + + Query struct { + Document func(childComplexity int, space string, id *string, path *string, rev *string) int + Documents func(childComplexity int, space string, rev *string) int + Project func(childComplexity int, owner string, name string) int + Projects func(childComplexity int) int + Proposals func(childComplexity int, space string, state model.ProposalState) int + Search func(childComplexity int, query string, spaces []string, limit *int, offset *int) int + Space func(childComplexity int, owner string, name string) int + Spaces func(childComplexity int) int + } + + SearchHit struct { + Anchor func(childComplexity int) int + ID func(childComplexity int) int + Lang func(childComplexity int) int + Path func(childComplexity int) int + Rev func(childComplexity int) int + Score func(childComplexity int) int + Section func(childComplexity int) int + Snippet func(childComplexity int) int + Space func(childComplexity int) int + Title func(childComplexity int) int + } + + SearchResults struct { + Hits func(childComplexity int) int + Took func(childComplexity int) int + Total func(childComplexity int) int + } + + Space struct { + ApprovedRev func(childComplexity int) int + Created func(childComplexity int) int + Name func(childComplexity int) int + Owner func(childComplexity int) int + Ref func(childComplexity int) int + } +} + +type ProjectResolver interface { + Spaces(ctx context.Context, obj *model.Project) ([]*model.Space, error) +} +type QueryResolver interface { + Spaces(ctx context.Context) ([]*model.Space, error) + Space(ctx context.Context, owner string, name string) (*model.Space, error) + Document(ctx context.Context, space string, id *string, path *string, rev *string) (*model.Document, error) + Documents(ctx context.Context, space string, rev *string) ([]*model.Document, error) + Search(ctx context.Context, query string, spaces []string, limit *int, offset *int) (*model.SearchResults, error) + Projects(ctx context.Context) ([]*model.Project, error) + Project(ctx context.Context, owner string, name string) (*model.Project, error) + Proposals(ctx context.Context, space string, state model.ProposalState) ([]*model.Proposal, error) +} +type SpaceResolver interface { + ApprovedRev(ctx context.Context, obj *model.Space) (string, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Document.blob": + if e.complexity.Document.Blob == nil { + break + } + + return e.complexity.Document.Blob(childComplexity), true + + case "Document.docId": + if e.complexity.Document.DocID == nil { + break + } + + return e.complexity.Document.DocID(childComplexity), true + + case "Document.id": + if e.complexity.Document.ID == nil { + break + } + + return e.complexity.Document.ID(childComplexity), true + + case "Document.markdown": + if e.complexity.Document.Markdown == nil { + break + } + + return e.complexity.Document.Markdown(childComplexity), true + + case "Document.owners": + if e.complexity.Document.Owners == nil { + break + } + + return e.complexity.Document.Owners(childComplexity), true + + case "Document.path": + if e.complexity.Document.Path == nil { + break + } + + return e.complexity.Document.Path(childComplexity), true + + case "Document.pinned": + if e.complexity.Document.Pinned == nil { + break + } + + return e.complexity.Document.Pinned(childComplexity), true + + case "Document.rev": + if e.complexity.Document.Rev == nil { + break + } + + return e.complexity.Document.Rev(childComplexity), true + + case "Document.section": + if e.complexity.Document.Section == nil { + break + } + + return e.complexity.Document.Section(childComplexity), true + + case "Document.space": + if e.complexity.Document.Space == nil { + break + } + + return e.complexity.Document.Space(childComplexity), true + + case "Document.status": + if e.complexity.Document.Status == nil { + break + } + + return e.complexity.Document.Status(childComplexity), true + + case "Document.summary": + if e.complexity.Document.Summary == nil { + break + } + + return e.complexity.Document.Summary(childComplexity), true + + case "Document.supersedes": + if e.complexity.Document.Supersedes == nil { + break + } + + return e.complexity.Document.Supersedes(childComplexity), true + + case "Document.tags": + if e.complexity.Document.Tags == nil { + break + } + + return e.complexity.Document.Tags(childComplexity), true + + case "Document.title": + if e.complexity.Document.Title == nil { + break + } + + return e.complexity.Document.Title(childComplexity), true + + case "Document.type": + if e.complexity.Document.Type == nil { + break + } + + return e.complexity.Document.Type(childComplexity), true + + case "Project.meta": + if e.complexity.Project.Meta == nil { + break + } + + return e.complexity.Project.Meta(childComplexity), true + + case "Project.name": + if e.complexity.Project.Name == nil { + break + } + + return e.complexity.Project.Name(childComplexity), true + + case "Project.owner": + if e.complexity.Project.Owner == nil { + break + } + + return e.complexity.Project.Owner(childComplexity), true + + case "Project.ref": + if e.complexity.Project.Ref == nil { + break + } + + return e.complexity.Project.Ref(childComplexity), true + + case "Project.spaces": + if e.complexity.Project.Spaces == nil { + break + } + + return e.complexity.Project.Spaces(childComplexity), true + + case "Proposal.agent": + if e.complexity.Proposal.Agent == nil { + break + } + + return e.complexity.Proposal.Agent(childComplexity), true + + case "Proposal.agentSession": + if e.complexity.Proposal.AgentSession == nil { + break + } + + return e.complexity.Proposal.AgentSession(childComplexity), true + + case "Proposal.approval": + if e.complexity.Proposal.Approval == nil { + break + } + + return e.complexity.Proposal.Approval(childComplexity), true + + case "Proposal.baseRev": + if e.complexity.Proposal.BaseRev == nil { + break + } + + return e.complexity.Proposal.BaseRev(childComplexity), true + + case "Proposal.branch": + if e.complexity.Proposal.Branch == nil { + break + } + + return e.complexity.Proposal.Branch(childComplexity), true + + case "Proposal.created": + if e.complexity.Proposal.Created == nil { + break + } + + return e.complexity.Proposal.Created(childComplexity), true + + case "Proposal.id": + if e.complexity.Proposal.ID == nil { + break + } + + return e.complexity.Proposal.ID(childComplexity), true + + case "Proposal.mergedRev": + if e.complexity.Proposal.MergedRev == nil { + break + } + + return e.complexity.Proposal.MergedRev(childComplexity), true + + case "Proposal.rationale": + if e.complexity.Proposal.Rationale == nil { + break + } + + return e.complexity.Proposal.Rationale(childComplexity), true + + case "Proposal.resolved": + if e.complexity.Proposal.Resolved == nil { + break + } + + return e.complexity.Proposal.Resolved(childComplexity), true + + case "Proposal.space": + if e.complexity.Proposal.Space == nil { + break + } + + return e.complexity.Proposal.Space(childComplexity), true + + case "Proposal.state": + if e.complexity.Proposal.State == nil { + break + } + + return e.complexity.Proposal.State(childComplexity), true + + case "Proposal.title": + if e.complexity.Proposal.Title == nil { + break + } + + return e.complexity.Proposal.Title(childComplexity), true + + case "Query.document": + if e.complexity.Query.Document == nil { + break + } + + args, err := ec.field_Query_document_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Document(childComplexity, args["space"].(string), args["id"].(*string), args["path"].(*string), args["rev"].(*string)), true + + case "Query.documents": + if e.complexity.Query.Documents == nil { + break + } + + args, err := ec.field_Query_documents_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Documents(childComplexity, args["space"].(string), args["rev"].(*string)), true + + case "Query.project": + if e.complexity.Query.Project == nil { + break + } + + args, err := ec.field_Query_project_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Project(childComplexity, args["owner"].(string), args["name"].(string)), true + + case "Query.projects": + if e.complexity.Query.Projects == nil { + break + } + + return e.complexity.Query.Projects(childComplexity), true + + case "Query.proposals": + if e.complexity.Query.Proposals == nil { + break + } + + args, err := ec.field_Query_proposals_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Proposals(childComplexity, args["space"].(string), args["state"].(model.ProposalState)), true + + case "Query.search": + if e.complexity.Query.Search == nil { + break + } + + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Search(childComplexity, args["query"].(string), args["spaces"].([]string), args["limit"].(*int), args["offset"].(*int)), true + + case "Query.space": + if e.complexity.Query.Space == nil { + break + } + + args, err := ec.field_Query_space_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Space(childComplexity, args["owner"].(string), args["name"].(string)), true + + case "Query.spaces": + if e.complexity.Query.Spaces == nil { + break + } + + return e.complexity.Query.Spaces(childComplexity), true + + case "SearchHit.anchor": + if e.complexity.SearchHit.Anchor == nil { + break + } + + return e.complexity.SearchHit.Anchor(childComplexity), true + + case "SearchHit.id": + if e.complexity.SearchHit.ID == nil { + break + } + + return e.complexity.SearchHit.ID(childComplexity), true + + case "SearchHit.lang": + if e.complexity.SearchHit.Lang == nil { + break + } + + return e.complexity.SearchHit.Lang(childComplexity), true + + case "SearchHit.path": + if e.complexity.SearchHit.Path == nil { + break + } + + return e.complexity.SearchHit.Path(childComplexity), true + + case "SearchHit.rev": + if e.complexity.SearchHit.Rev == nil { + break + } + + return e.complexity.SearchHit.Rev(childComplexity), true + + case "SearchHit.score": + if e.complexity.SearchHit.Score == nil { + break + } + + return e.complexity.SearchHit.Score(childComplexity), true + + case "SearchHit.section": + if e.complexity.SearchHit.Section == nil { + break + } + + return e.complexity.SearchHit.Section(childComplexity), true + + case "SearchHit.snippet": + if e.complexity.SearchHit.Snippet == nil { + break + } + + return e.complexity.SearchHit.Snippet(childComplexity), true + + case "SearchHit.space": + if e.complexity.SearchHit.Space == nil { + break + } + + return e.complexity.SearchHit.Space(childComplexity), true + + case "SearchHit.title": + if e.complexity.SearchHit.Title == nil { + break + } + + return e.complexity.SearchHit.Title(childComplexity), true + + case "SearchResults.hits": + if e.complexity.SearchResults.Hits == nil { + break + } + + return e.complexity.SearchResults.Hits(childComplexity), true + + case "SearchResults.took": + if e.complexity.SearchResults.Took == nil { + break + } + + return e.complexity.SearchResults.Took(childComplexity), true + + case "SearchResults.total": + if e.complexity.SearchResults.Total == nil { + break + } + + return e.complexity.SearchResults.Total(childComplexity), true + + case "Space.approvedRev": + if e.complexity.Space.ApprovedRev == nil { + break + } + + return e.complexity.Space.ApprovedRev(childComplexity), true + + case "Space.created": + if e.complexity.Space.Created == nil { + break + } + + return e.complexity.Space.Created(childComplexity), true + + case "Space.name": + if e.complexity.Space.Name == nil { + break + } + + return e.complexity.Space.Name(childComplexity), true + + case "Space.owner": + if e.complexity.Space.Owner == nil { + break + } + + return e.complexity.Space.Owner(childComplexity), true + + case "Space.ref": + if e.complexity.Space.Ref == nil { + break + } + + return e.complexity.Space.Ref(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schema.graphqls", Input: `# spec.sr.ht — the read schema. +# +# There are no mutations here and that is the design's decision, not an +# omission: the write plane's concurrency story is ` + "`" + `If-Match: ` + "`" + `, an +# HTTP idiom with well-defined 409 semantics that agents get right by default, +# and modelling base-rev as a mutation argument is a contract worth designing +# once, after the proposal state machine has stopped moving. Federated types are +# consumed contracts, so churning the proposal types here would be expensive. +# +# Everything this schema serves goes through service/ — the same functions the +# REST, MCP and web surfaces call — so the three agent-facing surfaces cannot +# disagree about what a document is or which revision is approved. + +""" +An RFC-3339 timestamp. +""" +scalar Time + +""" +The lifecycle of a proposal. Collapsed from the usual five states because there +is exactly one reviewer: "approve" is "merge now", and a proposal you dislike is +rejected rather than sent back for changes. +""" +enum ProposalState { + OPEN + MERGED + REJECTED +} + +""" +How a merge was authorized. Auto-merged is not human-approved, and readers must +be able to tell: a bot asking for the approved text of a spec should be able to +require human approval and get a different answer than for a firehose note. +""" +enum Approval { + HUMAN + POLICY +} + +type Query { + """ + Every space on the instance, ordered by owner then name. There is one human + here and no visibility levels, so there is nothing to filter: the list is the + whole corpus. + """ + spaces: [Space!]! + + """ + One space by reference. ` + "`" + `owner` + "`" + ` carries no leading '~' — that is routing + decoration, never part of the stored name. Null when there is no such space. + """ + space(owner: String!, name: String!): Space + + """ + One document of a space. + + Exactly one of ` + "`" + `id` + "`" + ` and ` + "`" + `path` + "`" + ` must be given. ` + "`" + `id` + "`" + ` is the document's address + under the design's rule: its frontmatter ` + "`" + `id:` + "`" + ` when that is well-formed and + unique in the space, and otherwise its path without the ".md" extension. An id + claimed by two documents resolves to neither — refusing to guess is the only + safe answer, since silently picking one would make links point at a document + the author did not mean. + + ` + "`" + `rev` + "`" + ` pins the read to an immutable revision and must be a full 40-character + object name; omit it to read the space's approved head, which is the default + because serving drafts by default would poison every downstream agent context + with unreviewed text. Ref names are refused, so there is no ` + "`" + `rev` + "`" + ` that makes + this field serve an unreviewed proposal branch. + + Null when the space, the revision or the document is absent. + """ + document(space: String!, id: String, path: String, rev: String): Document + + """ + Every document of a space at a revision, in tree order. ` + "`" + `rev` + "`" + ` follows the same + rule as on ` + "`" + `document` + "`" + `. + """ + documents(space: String!, rev: String): [Document!]! + + """ + Keyword search over the one global index. + + ` + "`" + `spaces` + "`" + ` is the project filter: a project is a saved filter over this index, + not a container, so searching a project means passing its member spaces here. + + Omitting the argument searches every space — that is the meta-project, a + filter that excludes nothing. Passing a list searches exactly those spaces, + and passing an *empty* list therefore searches nothing at all, which is what + an empty project's membership means. The two are different arguments here on + purpose: null and [] are distinct in GraphQL, so a client that resolved a + project to zero spaces cannot be handed the whole corpus by accident. + + An empty ` + "`" + `query` + "`" + ` returns no hits rather than every document: "search for + nothing" is a caller that has not collected its input yet. + """ + search(query: String!, spaces: [String!], limit: Int, offset: Int): SearchResults! + + """ + Every stored project, ordered by owner then name. The meta-project is not in + this list because it is not a row; it is an address that resolves to a filter, + and ` + "`" + `project(owner: ..., name: "everything")` + "`" + ` returns it. + """ + projects: [Project!]! + + """ + One project by reference. ` + "`" + `name` + "`" + ` carries no leading '+'. Null when there is no + such project. + """ + project(owner: String!, name: String!): Project + + """ + A space's proposals in one state, newest first. + + ` + "`" + `state` + "`" + ` is required. The proposal store lists by state, and an optional + argument would need an "every state" meaning for its absent case — the same + empty-means-everything polarity this schema refuses on ` + "`" + `search(spaces:)` + "`" + `. Ask + for the states you want, with aliases if you want more than one. + + This is a read: opening, merging and rejecting proposals are write-plane + operations and live on REST and MCP. + """ + proposals(space: String!, state: ProposalState!): [Proposal!]! +} + +""" +A space: one bare git repository, addressed ` + "`" + `~owner/name` + "`" + `. It is the unit of +ownership, ACL and review policy. +""" +type Space { + """The owning user, with no leading '~'.""" + owner: String! + name: String! + """The canonical reference, "~owner/name".""" + ref: String! + created: Time! + """ + The current tip of the approved branch, as a full object name. This is the + value to pin a later read to, and the value the write plane takes as + ` + "`" + `If-Match` + "`" + `. Resolving it opens the space's repository, so it is only paid for + when it is asked for. + """ + approvedRev: String! +} + +""" +A markdown document with YAML frontmatter, at one revision. A document reachable +from the approved ref is approved: approval is a property of the branch, never +of the frontmatter, which is why there is no "approved" field here and no +"approved" value in ` + "`" + `status` + "`" + `. +""" +type Document { + """The space this document belongs to, "~owner/name".""" + space: String! + """ + How this document is addressed: its frontmatter id when that is well-formed + and unique in the space, and its path without the extension otherwise. + """ + id: String! + """ + The frontmatter ` + "`" + `id:` + "`" + `, when the document has a well-formed one. Null when it + is absent or malformed. + + It is not always the same as ` + "`" + `id` + "`" + `: an id two documents claim resolves to + neither of them, so ` + "`" + `id` + "`" + ` falls back to the path there as well. ` + "`" + `id != docId` + "`" + ` + is precisely the set of documents that cannot be addressed by their id, which + is what an agent about to propose an edit needs to know. + """ + docId: String + """The document's path in the tree, extension included.""" + path: String! + """The commit this content was read at. Immutable: pass it back as ` + "`" + `rev` + "`" + `.""" + rev: String! + """The sha of this document's content. Changes only when the content does.""" + blob: String! + """ + Whether the caller named the revision. False means this is the approved head + as of this call — the reviewed, canonical text. + """ + pinned: Boolean! + """ + The document's title: its frontmatter ` + "`" + `title:` + "`" + `, then its first ` + "`" + `# heading` + "`" + `, + then its file name. Never empty — the chain is what keeps an untitled document + nameable rather than reported as blank. + """ + title: String! + """ + The authored lifecycle marker (draft, review, superseded). It is not approval + state. Empty when the frontmatter does not carry the key. + """ + status: String! + """The top-level directory the document lives under ("specs", "notes").""" + section: String! + """Authored metadata. Empty when the frontmatter does not carry the key.""" + summary: String! + type: String! + supersedes: String! + tags: [String!]! + owners: [String!]! + """The whole document, frontmatter included, exactly as stored.""" + markdown: String! +} + +""" +A project: a named set of spaces sharing one search scope, one MCP view and one +wikilink namespace. + +A project is pure metadata — a saved filter, not a container. It owns no index +and no storage, which is why it has no revision and no documents of its own. +""" +type Project { + """The owning user, with no leading '~'.""" + owner: String! + """The project name, with no leading '+'.""" + name: String! + """The canonical reference, "~owner/+name".""" + ref: String! + """ + Whether this is the meta-project: the degenerate filter that excludes nothing. + Its ` + "`" + `spaces` + "`" + ` is therefore every space as of this call rather than a stored + membership — a snapshot, which is why a query restricted to a project should + be built from the filter and not from a frozen list of names. + """ + meta: Boolean! + """ + The member spaces, ordered by owner then name. Empty for a project that + selects nothing, which is what a project with no members means. + """ + spaces: [Space!]! +} + +"""One page of ranked hits.""" +type SearchResults { + """How many documents matched, not how many were returned.""" + total: Int! + """How long the query took, as a Go duration string.""" + took: String! + hits: [SearchHit!]! +} + +""" +One ranked document. ` + "`" + `space` + "`" + `, ` + "`" + `path` + "`" + `, ` + "`" + `rev` + "`" + ` and ` + "`" + `anchor` + "`" + ` together are a pinned, +immutable address for the result. +""" +type SearchHit { + space: String! + """The document's address within its space, as ` + "`" + `Document.id` + "`" + ` reports it.""" + id: String! + rev: String! + path: String! + """The heading anchor within ` + "`" + `path` + "`" + `, set for one entry of an activity log.""" + anchor: String! + title: String! + section: String! + """The language the document was indexed as ("en", "ru").""" + lang: String! + score: Float! + """ + A fragment of the matching text with the matched terms wrapped in ` + "`" + `` + "`" + `. + Everything around them is HTML-escaped by the index, so this is HTML: render + it as HTML or strip the tags, but do not escape it again. + """ + snippet: String! +} + +""" +A bundle of document edits awaiting review: a branch ` + "`" + `proposals/` + "`" + ` plus a +row. Proposals are read-only here; they are opened over REST and MCP. +""" +type Proposal { + id: Int! + """The space the proposal is against, "~owner/name".""" + space: String! + title: String! + rationale: String! + """ + The approved-head sha the agent had read when it opened the proposal. It does + not move as the proposal accumulates edits. + """ + baseRev: String! + """The branch carrying the edits, "proposals/".""" + branch: String! + state: ProposalState! + """How the merge was authorized. Null until the proposal has merged.""" + approval: Approval + """The merge commit. Null until the proposal has merged.""" + mergedRev: String + """The agent identity that opened it, e.g. "claude-code/spec-writer".""" + agent: String! + """The agent's session id.""" + agentSession: String! + created: Time! + """When the proposal left the open state. Null while it is still open.""" + resolved: Time +} +`, BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_document_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["space"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("space")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["space"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg1 + var arg2 *string + if tmp, ok := rawArgs["path"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) + arg2, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["path"] = arg2 + var arg3 *string + if tmp, ok := rawArgs["rev"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("rev")) + arg3, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["rev"] = arg3 + return args, nil +} + +func (ec *executionContext) field_Query_documents_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["space"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("space")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["space"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["rev"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("rev")) + arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["rev"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Query_project_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["owner"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["owner"] = arg0 + var arg1 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Query_proposals_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["space"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("space")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["space"] = arg0 + var arg1 model.ProposalState + if tmp, ok := rawArgs["state"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + arg1, err = ec.unmarshalNProposalState2sourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalState(ctx, tmp) + if err != nil { + return nil, err + } + } + args["state"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["query"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["query"] = arg0 + var arg1 []string + if tmp, ok := rawArgs["spaces"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("spaces")) + arg1, err = ec.unmarshalOString2ᚕstringᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["spaces"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg2 + var arg3 *int + if tmp, ok := rawArgs["offset"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["offset"] = arg3 + return args, nil +} + +func (ec *executionContext) field_Query_space_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["owner"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["owner"] = arg0 + var arg1 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg1 + return args, nil +} + +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _Document_space(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_space(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Space, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_space(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_id(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_docId(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_docId(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DocID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_docId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_path(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_path(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Path, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_rev(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_rev(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Rev, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_rev(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_blob(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_blob(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Blob, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_blob(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_pinned(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_pinned(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Pinned, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_pinned(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_title(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_status(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_status(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Status, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_section(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_section(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Section, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_section(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_summary(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_summary(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Summary, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_summary(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_type(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_supersedes(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_supersedes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Supersedes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_supersedes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_tags(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_tags(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tags, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_owners(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_owners(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Owners, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_owners(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Document_markdown(ctx context.Context, field graphql.CollectedField, obj *model.Document) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Document_markdown(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Markdown, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Document_markdown(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Document", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Project_owner(ctx context.Context, field graphql.CollectedField, obj *model.Project) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Project_owner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Owner, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Project_owner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Project", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Project_name(ctx context.Context, field graphql.CollectedField, obj *model.Project) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Project_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Project_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Project", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Project_ref(ctx context.Context, field graphql.CollectedField, obj *model.Project) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Project_ref(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Ref, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Project_ref(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Project", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Project_meta(ctx context.Context, field graphql.CollectedField, obj *model.Project) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Project_meta(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Meta, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Project_meta(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Project", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Project_spaces(ctx context.Context, field graphql.CollectedField, obj *model.Project) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Project_spaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Project().Spaces(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Space) + fc.Result = res + return ec.marshalNSpace2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpaceᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Project_spaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Project", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "owner": + return ec.fieldContext_Space_owner(ctx, field) + case "name": + return ec.fieldContext_Space_name(ctx, field) + case "ref": + return ec.fieldContext_Space_ref(ctx, field) + case "created": + return ec.fieldContext_Space_created(ctx, field) + case "approvedRev": + return ec.fieldContext_Space_approvedRev(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Space", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_id(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_space(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_space(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Space, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_space(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_title(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_rationale(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_rationale(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Rationale, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_rationale(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_baseRev(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_baseRev(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.BaseRev, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_baseRev(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_branch(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_branch(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Branch, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_branch(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_state(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_state(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.State, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(model.ProposalState) + fc.Result = res + return ec.marshalNProposalState2sourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalState(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_state(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ProposalState does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_approval(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_approval(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Approval, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Approval) + fc.Result = res + return ec.marshalOApproval2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐApproval(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_approval(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Approval does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_mergedRev(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_mergedRev(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MergedRev, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_mergedRev(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_agent(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_agent(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Agent, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_agent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_agentSession(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_agentSession(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AgentSession, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_agentSession(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_created(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Proposal_resolved(ctx context.Context, field graphql.CollectedField, obj *model.Proposal) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Proposal_resolved(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Resolved, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Proposal_resolved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Proposal", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_spaces(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_spaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Spaces(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Space) + fc.Result = res + return ec.marshalNSpace2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpaceᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_spaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "owner": + return ec.fieldContext_Space_owner(ctx, field) + case "name": + return ec.fieldContext_Space_name(ctx, field) + case "ref": + return ec.fieldContext_Space_ref(ctx, field) + case "created": + return ec.fieldContext_Space_created(ctx, field) + case "approvedRev": + return ec.fieldContext_Space_approvedRev(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Space", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_space(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_space(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Space(rctx, fc.Args["owner"].(string), fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Space) + fc.Result = res + return ec.marshalOSpace2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpace(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_space(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "owner": + return ec.fieldContext_Space_owner(ctx, field) + case "name": + return ec.fieldContext_Space_name(ctx, field) + case "ref": + return ec.fieldContext_Space_ref(ctx, field) + case "created": + return ec.fieldContext_Space_created(ctx, field) + case "approvedRev": + return ec.fieldContext_Space_approvedRev(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Space", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_space_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_document(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_document(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Document(rctx, fc.Args["space"].(string), fc.Args["id"].(*string), fc.Args["path"].(*string), fc.Args["rev"].(*string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Document) + fc.Result = res + return ec.marshalODocument2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocument(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_document(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "space": + return ec.fieldContext_Document_space(ctx, field) + case "id": + return ec.fieldContext_Document_id(ctx, field) + case "docId": + return ec.fieldContext_Document_docId(ctx, field) + case "path": + return ec.fieldContext_Document_path(ctx, field) + case "rev": + return ec.fieldContext_Document_rev(ctx, field) + case "blob": + return ec.fieldContext_Document_blob(ctx, field) + case "pinned": + return ec.fieldContext_Document_pinned(ctx, field) + case "title": + return ec.fieldContext_Document_title(ctx, field) + case "status": + return ec.fieldContext_Document_status(ctx, field) + case "section": + return ec.fieldContext_Document_section(ctx, field) + case "summary": + return ec.fieldContext_Document_summary(ctx, field) + case "type": + return ec.fieldContext_Document_type(ctx, field) + case "supersedes": + return ec.fieldContext_Document_supersedes(ctx, field) + case "tags": + return ec.fieldContext_Document_tags(ctx, field) + case "owners": + return ec.fieldContext_Document_owners(ctx, field) + case "markdown": + return ec.fieldContext_Document_markdown(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Document", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_document_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_documents(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_documents(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Documents(rctx, fc.Args["space"].(string), fc.Args["rev"].(*string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Document) + fc.Result = res + return ec.marshalNDocument2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocumentᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_documents(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "space": + return ec.fieldContext_Document_space(ctx, field) + case "id": + return ec.fieldContext_Document_id(ctx, field) + case "docId": + return ec.fieldContext_Document_docId(ctx, field) + case "path": + return ec.fieldContext_Document_path(ctx, field) + case "rev": + return ec.fieldContext_Document_rev(ctx, field) + case "blob": + return ec.fieldContext_Document_blob(ctx, field) + case "pinned": + return ec.fieldContext_Document_pinned(ctx, field) + case "title": + return ec.fieldContext_Document_title(ctx, field) + case "status": + return ec.fieldContext_Document_status(ctx, field) + case "section": + return ec.fieldContext_Document_section(ctx, field) + case "summary": + return ec.fieldContext_Document_summary(ctx, field) + case "type": + return ec.fieldContext_Document_type(ctx, field) + case "supersedes": + return ec.fieldContext_Document_supersedes(ctx, field) + case "tags": + return ec.fieldContext_Document_tags(ctx, field) + case "owners": + return ec.fieldContext_Document_owners(ctx, field) + case "markdown": + return ec.fieldContext_Document_markdown(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Document", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_documents_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_search(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, fc.Args["query"].(string), fc.Args["spaces"].([]string), fc.Args["limit"].(*int), fc.Args["offset"].(*int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.SearchResults) + fc.Result = res + return ec.marshalNSearchResults2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchResults(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "total": + return ec.fieldContext_SearchResults_total(ctx, field) + case "took": + return ec.fieldContext_SearchResults_took(ctx, field) + case "hits": + return ec.fieldContext_SearchResults_hits(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SearchResults", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_search_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_projects(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Projects(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Project) + fc.Result = res + return ec.marshalNProject2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProjectᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_projects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "owner": + return ec.fieldContext_Project_owner(ctx, field) + case "name": + return ec.fieldContext_Project_name(ctx, field) + case "ref": + return ec.fieldContext_Project_ref(ctx, field) + case "meta": + return ec.fieldContext_Project_meta(ctx, field) + case "spaces": + return ec.fieldContext_Project_spaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Project", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_project(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_project(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Project(rctx, fc.Args["owner"].(string), fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Project) + fc.Result = res + return ec.marshalOProject2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_project(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "owner": + return ec.fieldContext_Project_owner(ctx, field) + case "name": + return ec.fieldContext_Project_name(ctx, field) + case "ref": + return ec.fieldContext_Project_ref(ctx, field) + case "meta": + return ec.fieldContext_Project_meta(ctx, field) + case "spaces": + return ec.fieldContext_Project_spaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Project", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_project_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_proposals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_proposals(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Proposals(rctx, fc.Args["space"].(string), fc.Args["state"].(model.ProposalState)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Proposal) + fc.Result = res + return ec.marshalNProposal2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_proposals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Proposal_id(ctx, field) + case "space": + return ec.fieldContext_Proposal_space(ctx, field) + case "title": + return ec.fieldContext_Proposal_title(ctx, field) + case "rationale": + return ec.fieldContext_Proposal_rationale(ctx, field) + case "baseRev": + return ec.fieldContext_Proposal_baseRev(ctx, field) + case "branch": + return ec.fieldContext_Proposal_branch(ctx, field) + case "state": + return ec.fieldContext_Proposal_state(ctx, field) + case "approval": + return ec.fieldContext_Proposal_approval(ctx, field) + case "mergedRev": + return ec.fieldContext_Proposal_mergedRev(ctx, field) + case "agent": + return ec.fieldContext_Proposal_agent(ctx, field) + case "agentSession": + return ec.fieldContext_Proposal_agentSession(ctx, field) + case "created": + return ec.fieldContext_Proposal_created(ctx, field) + case "resolved": + return ec.fieldContext_Proposal_resolved(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Proposal", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_proposals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_space(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_space(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Space, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_space(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_id(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_rev(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_rev(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Rev, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_rev(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_path(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_path(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Path, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_anchor(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_anchor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Anchor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_anchor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_title(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_section(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_section(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Section, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_section(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_lang(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_lang(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Lang, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_lang(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_score(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_score(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Score, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_score(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchHit_snippet(ctx context.Context, field graphql.CollectedField, obj *model.SearchHit) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchHit_snippet(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Snippet, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchHit_snippet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchHit", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchResults_total(ctx context.Context, field graphql.CollectedField, obj *model.SearchResults) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchResults_total(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Total, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchResults_total(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchResults", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchResults_took(ctx context.Context, field graphql.CollectedField, obj *model.SearchResults) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchResults_took(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Took, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchResults_took(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchResults", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SearchResults_hits(ctx context.Context, field graphql.CollectedField, obj *model.SearchResults) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SearchResults_hits(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hits, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.SearchHit) + fc.Result = res + return ec.marshalNSearchHit2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchHitᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SearchResults_hits(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SearchResults", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "space": + return ec.fieldContext_SearchHit_space(ctx, field) + case "id": + return ec.fieldContext_SearchHit_id(ctx, field) + case "rev": + return ec.fieldContext_SearchHit_rev(ctx, field) + case "path": + return ec.fieldContext_SearchHit_path(ctx, field) + case "anchor": + return ec.fieldContext_SearchHit_anchor(ctx, field) + case "title": + return ec.fieldContext_SearchHit_title(ctx, field) + case "section": + return ec.fieldContext_SearchHit_section(ctx, field) + case "lang": + return ec.fieldContext_SearchHit_lang(ctx, field) + case "score": + return ec.fieldContext_SearchHit_score(ctx, field) + case "snippet": + return ec.fieldContext_SearchHit_snippet(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SearchHit", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Space_owner(ctx context.Context, field graphql.CollectedField, obj *model.Space) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Space_owner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Owner, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Space_owner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Space", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Space_name(ctx context.Context, field graphql.CollectedField, obj *model.Space) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Space_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Space_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Space", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Space_ref(ctx context.Context, field graphql.CollectedField, obj *model.Space) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Space_ref(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Ref, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Space_ref(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Space", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Space_created(ctx context.Context, field graphql.CollectedField, obj *model.Space) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Space_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Space_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Space", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Space_approvedRev(ctx context.Context, field graphql.CollectedField, obj *model.Space) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Space_approvedRev(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Space().ApprovedRev(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Space_approvedRev(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Space", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsRepeatable, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var documentImplementors = []string{"Document"} + +func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet, obj *model.Document) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, documentImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Document") + case "space": + out.Values[i] = ec._Document_space(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "id": + out.Values[i] = ec._Document_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "docId": + out.Values[i] = ec._Document_docId(ctx, field, obj) + case "path": + out.Values[i] = ec._Document_path(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "rev": + out.Values[i] = ec._Document_rev(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "blob": + out.Values[i] = ec._Document_blob(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pinned": + out.Values[i] = ec._Document_pinned(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "title": + out.Values[i] = ec._Document_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "status": + out.Values[i] = ec._Document_status(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "section": + out.Values[i] = ec._Document_section(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "summary": + out.Values[i] = ec._Document_summary(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec._Document_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "supersedes": + out.Values[i] = ec._Document_supersedes(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "tags": + out.Values[i] = ec._Document_tags(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "owners": + out.Values[i] = ec._Document_owners(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "markdown": + out.Values[i] = ec._Document_markdown(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var projectImplementors = []string{"Project"} + +func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *model.Project) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Project") + case "owner": + out.Values[i] = ec._Project_owner(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Project_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "ref": + out.Values[i] = ec._Project_ref(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "meta": + out.Values[i] = ec._Project_meta(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "spaces": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Project_spaces(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var proposalImplementors = []string{"Proposal"} + +func (ec *executionContext) _Proposal(ctx context.Context, sel ast.SelectionSet, obj *model.Proposal) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, proposalImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Proposal") + case "id": + out.Values[i] = ec._Proposal_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "space": + out.Values[i] = ec._Proposal_space(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "title": + out.Values[i] = ec._Proposal_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "rationale": + out.Values[i] = ec._Proposal_rationale(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "baseRev": + out.Values[i] = ec._Proposal_baseRev(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "branch": + out.Values[i] = ec._Proposal_branch(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "state": + out.Values[i] = ec._Proposal_state(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "approval": + out.Values[i] = ec._Proposal_approval(ctx, field, obj) + case "mergedRev": + out.Values[i] = ec._Proposal_mergedRev(ctx, field, obj) + case "agent": + out.Values[i] = ec._Proposal_agent(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "agentSession": + out.Values[i] = ec._Proposal_agentSession(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "created": + out.Values[i] = ec._Proposal_created(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resolved": + out.Values[i] = ec._Proposal_resolved(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var queryImplementors = []string{"Query"} + +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "spaces": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_spaces(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "space": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_space(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "document": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_document(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "documents": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_documents(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "search": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_search(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "projects": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_projects(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "project": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_project(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "proposals": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_proposals(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var searchHitImplementors = []string{"SearchHit"} + +func (ec *executionContext) _SearchHit(ctx context.Context, sel ast.SelectionSet, obj *model.SearchHit) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, searchHitImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SearchHit") + case "space": + out.Values[i] = ec._SearchHit_space(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "id": + out.Values[i] = ec._SearchHit_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "rev": + out.Values[i] = ec._SearchHit_rev(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "path": + out.Values[i] = ec._SearchHit_path(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "anchor": + out.Values[i] = ec._SearchHit_anchor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "title": + out.Values[i] = ec._SearchHit_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "section": + out.Values[i] = ec._SearchHit_section(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "lang": + out.Values[i] = ec._SearchHit_lang(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "score": + out.Values[i] = ec._SearchHit_score(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "snippet": + out.Values[i] = ec._SearchHit_snippet(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var searchResultsImplementors = []string{"SearchResults"} + +func (ec *executionContext) _SearchResults(ctx context.Context, sel ast.SelectionSet, obj *model.SearchResults) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, searchResultsImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SearchResults") + case "total": + out.Values[i] = ec._SearchResults_total(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "took": + out.Values[i] = ec._SearchResults_took(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hits": + out.Values[i] = ec._SearchResults_hits(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var spaceImplementors = []string{"Space"} + +func (ec *executionContext) _Space(ctx context.Context, sel ast.SelectionSet, obj *model.Space) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, spaceImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Space") + case "owner": + out.Values[i] = ec._Space_owner(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Space_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "ref": + out.Values[i] = ec._Space_ref(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "created": + out.Values[i] = ec._Space_created(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "approvedRev": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Space_approvedRev(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __FieldImplementors = []string{"__Field"} + +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var __TypeImplementors = []string{"__Type"} + +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNDocument2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocumentᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Document) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNDocument2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocument(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNDocument2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocument(ctx context.Context, sel ast.SelectionSet, v *model.Document) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Document(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { + res, err := graphql.UnmarshalFloatContext(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + res := graphql.MarshalFloatContext(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { + res, err := graphql.UnmarshalInt(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + res := graphql.MarshalInt(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNProject2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProjectᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Project) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNProject2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProject(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNProject2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProject(ctx context.Context, sel ast.SelectionSet, v *model.Project) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Project(ctx, sel, v) +} + +func (ec *executionContext) marshalNProposal2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Proposal) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNProposal2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposal(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNProposal2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposal(ctx context.Context, sel ast.SelectionSet, v *model.Proposal) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Proposal(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNProposalState2sourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalState(ctx context.Context, v interface{}) (model.ProposalState, error) { + var res model.ProposalState + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNProposalState2sourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProposalState(ctx context.Context, sel ast.SelectionSet, v model.ProposalState) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNSearchHit2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchHitᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.SearchHit) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNSearchHit2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchHit(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNSearchHit2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchHit(ctx context.Context, sel ast.SelectionSet, v *model.SearchHit) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._SearchHit(ctx, sel, v) +} + +func (ec *executionContext) marshalNSearchResults2sourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchResults(ctx context.Context, sel ast.SelectionSet, v model.SearchResults) graphql.Marshaler { + return ec._SearchResults(ctx, sel, &v) +} + +func (ec *executionContext) marshalNSearchResults2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSearchResults(ctx context.Context, sel ast.SelectionSet, v *model.SearchResults) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._SearchResults(ctx, sel, v) +} + +func (ec *executionContext) marshalNSpace2ᚕᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpaceᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Space) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNSpace2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpace(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNSpace2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpace(ctx context.Context, sel ast.SelectionSet, v *model.Space) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Space(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + res, err := graphql.UnmarshalTime(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + res := graphql.MarshalTime(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalOApproval2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐApproval(ctx context.Context, v interface{}) (*model.Approval, error) { + if v == nil { + return nil, nil + } + var res = new(model.Approval) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOApproval2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐApproval(ctx context.Context, sel ast.SelectionSet, v *model.Approval) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + return res +} + +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalBoolean(*v) + return res +} + +func (ec *executionContext) marshalODocument2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐDocument(ctx context.Context, sel ast.SelectionSet, v *model.Document) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Document(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalInt(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalInt(*v) + return res +} + +func (ec *executionContext) marshalOProject2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐProject(ctx context.Context, sel ast.SelectionSet, v *model.Project) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Project(ctx, sel, v) +} + +func (ec *executionContext) marshalOSpace2ᚖsourcecraftᚗdevᚋbigbesᚋsrᚑhtᚑspecᚋgraphᚋmodelᚐSpace(ctx context.Context, sel ast.SelectionSet, v *model.Space) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Space(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalTime(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalTime(*v) + return res +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/graph/generate.go b/graph/generate.go new file mode 100644 index 0000000000000000000000000000000000000000..5f45a5d384bd3555ed85dea10ff5d6b3c8184eb1 --- /dev/null +++ b/graph/generate.go @@ -0,0 +1,18 @@ +package graph + +// Code generation. gqlgen reads gqlgen.yml in this directory and rewrites +// api/generated.go, model/models_gen.go and the stubs in schema.resolvers.go; +// implementations already in that file are carried through untouched. +// +// It is run through the module graph rather than as `go run +// github.com/99designs/gqlgen@v0.17.36`: gqlgen v0.17.36's own module pins +// golang.org/x/tools v0.9.3, which does not compile under this toolchain, while +// the version this module selects does. +// +// The generator is deliberately not imported anywhere. A blank import under a +// `generate` build tag — which is how git.sr.ht's api/graph does it — would put +// the whole codegen dependency tree (a CLI framework, a markdown renderer, the +// Go analysis packages) into this service's go.mod permanently, for the sake of +// a tool that runs when the schema changes. +// +//go:generate go run github.com/99designs/gqlgen generate diff --git a/graph/gqlgen.yml b/graph/gqlgen.yml new file mode 100644 index 0000000000000000000000000000000000000000..c56a4d21e90fa9700a02b508e25bff89ae0022df --- /dev/null +++ b/graph/gqlgen.yml @@ -0,0 +1,30 @@ +# gqlgen configuration. Run `go generate ./graph` from the repository root, or +# `gqlgen` from this directory; every path below is relative to this file. +# +# The layout mirrors git.sr.ht's api/: the schema beside the resolvers, the +# executable schema in its own package so nothing but the server touches it, and +# hand-written models autobound by name. +schema: + - schema.graphqls + +exec: + filename: api/generated.go + package: api + +model: + filename: model/models_gen.go + package: model + +resolver: + layout: follow-schema + dir: . + package: graph + +# Federation into api.sr.ht is a config line on the gateway, not a build-time +# decision here: `api-origin=` points it at our own /query. It is deliberately +# left off — nothing about this schema depends on the gateway existing. + +autobind: + - "sourcecraft.dev/bigbes/sr-ht-spec/graph/model" + +omit_getters: true diff --git a/graph/graph_test.go b/graph/graph_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8e4e227c06416dfb107f564d228c254ff3a2a68f --- /dev/null +++ b/graph/graph_test.go @@ -0,0 +1,1075 @@ +package graph + +import ( + "context" + "crypto/rand" + "crypto/sha1" + "encoding/base64" + "encoding/hex" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "sort" + "strings" + "testing" + "time" + + "github.com/fernet/fernet-go" + "github.com/go-chi/chi/v5" + "github.com/vaughan0/go-ini" + "sourcecraft.dev/bigbes/sr-ht-core/crypto" + + "sourcecraft.dev/bigbes/sr-ht-spec/authn" + "sourcecraft.dev/bigbes/sr-ht-spec/core" + "sourcecraft.dev/bigbes/sr-ht-spec/doc" + "sourcecraft.dev/bigbes/sr-ht-spec/search" + "sourcecraft.dev/bigbes/sr-ht-spec/service" +) + +// testConf carries the crypto keys established in TestMain, so a test can seal +// a unified-login cookie the way meta.sr.ht does and drive the schema through +// the same middleware the daemon installs. +var testConf ini.File + +func TestMain(m *testing.M) { + var fk fernet.Key + if err := fk.Generate(); err != nil { + panic("generate fernet key: " + err.Error()) + } + seed := make([]byte, 32) + if _, err := rand.Read(seed); err != nil { + panic("generate webhook seed: " + err.Error()) + } + testConf = ini.File{ + "sr.ht": ini.Section{"network-key": fk.Encode()}, + "webhooks": ini.Section{"private-key": base64.StdEncoding.EncodeToString(seed)}, + } + crypto.InitCrypto(testConf) + os.Exit(m.Run()) +} + +// ---- fixtures ------------------------------------------------------------- + +const ( + headRev = "1111111111111111111111111111111111111111" + oldRev = "2222222222222222222222222222222222222222" + absentRev = "3333333333333333333333333333333333333333" + agentTk = "test-agent-token" +) + +var ( + demoSpace = core.SpaceRef{Owner: "bigbes", Name: "rfcs"} + otherSpace = core.SpaceRef{Owner: "bigbes", Name: "notes"} + + fullProject = core.ProjectRef{Owner: "bigbes", Name: "docs"} + emptyProject = core.ProjectRef{Owner: "bigbes", Name: "fresh"} + + created = time.Date(2026, 7, 22, 10, 0, 0, 0, time.UTC) +) + +// headDocs is the demo space at its approved head. notes/plain.md carries no +// frontmatter at all and is therefore addressed by its path; SPEC-0009 is +// claimed twice, so it resolves to neither of its claimants. +var headDocs = map[string]string{ + "specs/0007-storage.md": `--- +id: SPEC-0007 +title: Proposal storage model +status: draft +type: spec +supersedes: SPEC-0003 +owners: [~bigbes] +tags: [storage, review] +summary: How proposals are stored. +--- + +# Proposal storage model + +Git is authoritative. +`, + "specs/0009-a.md": `--- +id: SPEC-0009 +title: One claimant +status: draft +--- + +# One claimant +`, + "specs/0009-b.md": `--- +id: SPEC-0009 +title: The other claimant +status: draft +--- + +# The other claimant +`, + "notes/plain.md": `# Just a note + +No frontmatter here at all. +`, +} + +// oldDocs is the same space at a pinned, older revision. The title differs, so +// a test can prove that `rev:` actually reached a different tree. +var oldDocs = map[string]string{ + "specs/0007-storage.md": `--- +id: SPEC-0007 +title: Storage, first draft +status: draft +--- + +# Storage, first draft +`, +} + +// fakeReader is an in-memory Reader: a space is a revision-keyed set of +// documents, and a project is a list of member spaces. +type fakeReader struct { + revs map[string]map[string]string // rev -> path -> content + head string + projects map[core.ProjectRef][]core.SpaceRef +} + +func newFakeReader() *fakeReader { + return &fakeReader{ + revs: map[string]map[string]string{headRev: headDocs, oldRev: oldDocs}, + head: headRev, + projects: map[core.ProjectRef][]core.SpaceRef{ + fullProject: {demoSpace}, + emptyProject: nil, + }, + } +} + +func spaceOf(ref core.SpaceRef) *service.Space { + return &service.Space{Ref: ref, ID: 1, Created: created} +} + +func (f *fakeReader) ListSpaces(context.Context) ([]*service.Space, error) { + return []*service.Space{spaceOf(demoSpace), spaceOf(otherSpace)}, nil +} + +func (f *fakeReader) OpenSpace(_ context.Context, ref core.SpaceRef) (*service.Space, error) { + if ref != demoSpace { + return nil, fmt.Errorf("%w: space %s", service.ErrNotFound, ref) + } + return spaceOf(ref), nil +} + +// at resolves a revision the way service does: ApprovedRev is the approved +// head, and anything else must name a revision that exists. +func (f *fakeReader) at(rev string) (string, map[string]string, error) { + if rev == service.ApprovedRev { + rev = f.head + } + docs, ok := f.revs[rev] + if !ok { + return "", nil, fmt.Errorf("%w: revision %q", service.ErrNotFound, rev) + } + return rev, docs, nil +} + +func (f *fakeReader) ResolveRev(_ context.Context, _ *service.Space, rev string) (string, error) { + resolved, _, err := f.at(rev) + return resolved, err +} + +func (f *fakeReader) Archive(_ context.Context, sp *service.Space, rev string) (*doc.Archive, map[string][]byte, error) { + resolved, docs, err := f.at(rev) + if err != nil { + return nil, nil, err + } + paths := make([]string, 0, len(docs)) + for p := range docs { + paths = append(paths, p) + } + sort.Strings(paths) + + // Built through service.ArchiveFrom, which is the seam it exists for: the + // addressing rule under test is the production one rather than a fixture's + // idea of it. + sd := make([]service.Document, 0, len(paths)) + for _, p := range paths { + data := []byte(docs[p]) + sd = append(sd, service.Document{Path: p, Blob: blobSha(data), Rev: resolved, Data: data}) + } + return service.ArchiveFrom(sp.Ref, resolved, sd) +} + +func (f *fakeReader) GetProject(_ context.Context, ref core.ProjectRef) (*service.Project, error) { + if _, ok := f.projects[ref]; !ok { + return nil, fmt.Errorf("%w: project %s", service.ErrNotFound, ref) + } + return &service.Project{Ref: ref, ID: 1, Created: created}, nil +} + +func (f *fakeReader) ListProjects(context.Context) ([]*service.Project, error) { + return []*service.Project{ + {Ref: fullProject, ID: 1, Created: created}, + {Ref: emptyProject, ID: 2, Created: created}, + }, nil +} + +func (f *fakeReader) ProjectSpaces(_ context.Context, ref core.ProjectRef) ([]*service.Space, error) { + // The meta-project lists every space, exactly as service.ProjectSpaces does: + // a listing is enumerated by definition, even though the filter it resolves + // to is not. + if ref.IsMeta() { + return f.ListSpaces(context.Background()) + } + members, ok := f.projects[ref] + if !ok { + return nil, fmt.Errorf("%w: project %s", service.ErrNotFound, ref) + } + out := make([]*service.Space, 0, len(members)) + for _, m := range members { + out = append(out, spaceOf(m)) + } + return out, nil +} + +// blobSha is git's object name for a blob: sha1 over "blob \0" and the +// content. Spelled out rather than taken from go-git so that this package — +// tests included — never imports the git layer, which is the whole point of +// reading through service/. +func blobSha(data []byte) string { + h := sha1.New() + fmt.Fprintf(h, "blob %d", len(data)) + h.Write([]byte{0}) + h.Write(data) + return hex.EncodeToString(h.Sum(nil)) +} + +// fakeSearcher records the query it was handed and returns one fixed hit. +type fakeSearcher struct { + last search.Query +} + +func (s *fakeSearcher) Search(_ context.Context, q search.Query) (search.Results, error) { + s.last = q + // The two answers the index knows without looking, spelled the same way + // search.Index spells them: a scope nobody set is a caller bug, and a + // filter that selects no space has no hits by construction. + if q.Spaces.IsZero() { + return search.Results{}, fmt.Errorf("search: query names no space scope") + } + if q.Spaces.MatchesNothing() { + return search.Results{}, nil + } + return search.Results{ + Total: 1, + Took: 3 * time.Millisecond, + Hits: []search.Hit{{ + Space: demoSpace, + ID: "SPEC-0007", + Rev: headRev, + Path: "specs/0007-storage.md", + Title: "Proposal storage model", + Section: "specs", + Lang: search.LangEN, + Score: 1.5, + Snippet: `Git is authoritative & boring`, + }}, + }, nil +} + +// fakeProposals is the port service/ does not implement yet. +type fakeProposals struct { + rows []Proposal +} + +func (f *fakeProposals) ListProposals(_ context.Context, space core.SpaceRef, state core.ProposalState) ([]Proposal, error) { + var out []Proposal + for _, p := range f.rows { + if p.Space == space && p.State == state { + out = append(out, p) + } + } + return out, nil +} + +// stubTokenStore knows exactly one live agent token. +type stubTokenStore struct{} + +func (stubTokenStore) LookupAgentToken(_ context.Context, hash []byte) (authn.AgentToken, error) { + want := authn.HashToken(agentTk) + if string(hash) != string(want) { + return authn.AgentToken{}, authn.ErrUnknownToken + } + return authn.AgentToken{ID: 1, Name: "test", Hash: want}, nil +} + +// ---- harness -------------------------------------------------------------- + +type harness struct { + handler http.Handler + searcher *fakeSearcher + proposals *fakeProposals +} + +func newHarness(t *testing.T, withProposals bool) harness { + t.Helper() + resolver, err := authn.NewResolver("bigbes", stubTokenStore{}) + if err != nil { + t.Fatalf("NewResolver: %v", err) + } + searcher := &fakeSearcher{} + opts := Options{Reader: newFakeReader(), Searcher: searcher, Resolver: resolver} + var proposals *fakeProposals + if withProposals { + proposals = &fakeProposals{} + opts.Proposals = proposals + } + srv, err := New(opts) + if err != nil { + t.Fatalf("New: %v", err) + } + return harness{handler: srv.Handler(), searcher: searcher, proposals: proposals} +} + +// response is one GraphQL response, decoded far enough to assert on. +type response struct { + status int + body string + Data json.RawMessage `json:"data"` + Errors []graphqlError `json:"errors"` +} + +type graphqlError struct { + Message string `json:"message"` +} + +// errText joins every error message, for assertions that care what was said. +func (r response) errText() string { + var msgs []string + for _, e := range r.Errors { + msgs = append(msgs, e.Message) + } + return strings.Join(msgs, "; ") +} + +// query POSTs a GraphQL query as the instance owner. +func query(t *testing.T, h harness, q string) response { + t.Helper() + return post(t, h, q, func(req *http.Request) { login(req, "bigbes") }) +} + +func post(t *testing.T, h harness, q string, auth func(*http.Request)) response { + t.Helper() + body, err := json.Marshal(map[string]any{"query": q}) + if err != nil { + t.Fatalf("marshal query: %v", err) + } + req := httptest.NewRequest(http.MethodPost, "/query", strings.NewReader(string(body))) + req.Header.Set("Content-Type", "application/json") + if auth != nil { + auth(req) + } + rec := httptest.NewRecorder() + h.handler.ServeHTTP(rec, req) + + out := response{status: rec.Code, body: rec.Body.String()} + if strings.HasPrefix(rec.Header().Get("Content-Type"), "application/json") { + if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil { + t.Fatalf("decode response %q: %v", rec.Body.String(), err) + } + } + return out +} + +// ok fails unless the query succeeded outright, and decodes data into v. +func ok(t *testing.T, r response, v any) { + t.Helper() + if r.status != http.StatusOK { + t.Fatalf("status %d, body %s", r.status, r.body) + } + if len(r.Errors) > 0 { + t.Fatalf("unexpected errors: %s", r.errText()) + } + if v != nil { + if err := json.Unmarshal(r.Data, v); err != nil { + t.Fatalf("decode data %s: %v", r.Data, err) + } + } +} + +// login seals a unified-login cookie for user onto a request — the same shape +// meta.sr.ht writes, sealed with the shared network key. +func login(req *http.Request, user string) { + payload, _ := json.Marshal(map[string]string{"name": user}) + req.AddCookie(&http.Cookie{Name: authn.CookieName, Value: string(crypto.Encrypt(payload))}) +} + +// ---- the read contract ---------------------------------------------------- + +// A read with no rev is a read of the approved head, and reports the sha it +// resolved to so the caller can pin the next one. +func TestDocumentDefaultsToTheApprovedHead(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ + document(space: "~bigbes/rfcs", id: "SPEC-0007") { + id docId path rev blob pinned title status section summary type supersedes tags owners markdown + } + }`) + + var got struct { + Document struct { + ID, Path, Rev, Blob string + DocID *string + Pinned bool + Title, Status, Section string + Summary, Type, Supersedes string + Tags, Owners []string + Markdown string + } + } + ok(t, r, &got) + + if got.Document.Rev != headRev { + t.Errorf("rev = %q, want the approved head %q", got.Document.Rev, headRev) + } + if got.Document.Pinned { + t.Error("pinned = true for a read that named no revision") + } + if got.Document.Title != "Proposal storage model" { + t.Errorf("title = %q, want the head's title", got.Document.Title) + } + if got.Document.ID != "SPEC-0007" || got.Document.DocID == nil || *got.Document.DocID != "SPEC-0007" { + t.Errorf("id/docId = %q/%v, want both SPEC-0007", got.Document.ID, got.Document.DocID) + } + if got.Document.Path != "specs/0007-storage.md" { + t.Errorf("path = %q", got.Document.Path) + } + if got.Document.Blob != blobSha([]byte(headDocs["specs/0007-storage.md"])) { + t.Errorf("blob = %q, want the content hash", got.Document.Blob) + } + if got.Document.Section != "specs" || got.Document.Status != "draft" { + t.Errorf("section/status = %q/%q", got.Document.Section, got.Document.Status) + } + if got.Document.Type != "spec" || got.Document.Supersedes != "SPEC-0003" { + t.Errorf("type/supersedes = %q/%q", got.Document.Type, got.Document.Supersedes) + } + if strings.Join(got.Document.Tags, ",") != "storage,review" { + t.Errorf("tags = %v", got.Document.Tags) + } + if strings.Join(got.Document.Owners, ",") != "~bigbes" { + t.Errorf("owners = %v", got.Document.Owners) + } + if !strings.HasPrefix(got.Document.Markdown, "---\nid: SPEC-0007") { + t.Errorf("markdown does not carry the frontmatter: %q", got.Document.Markdown) + } +} + +// A full object name pins the read to that revision, and says so. +func TestDocumentPinnedToARevision(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ + document(space: "~bigbes/rfcs", id: "SPEC-0007", rev: "`+oldRev+`") { rev pinned title } + }`) + + var got struct { + Document struct { + Rev string + Pinned bool + Title string + } + } + ok(t, r, &got) + + if got.Document.Rev != oldRev { + t.Errorf("rev = %q, want the pinned %q", got.Document.Rev, oldRev) + } + if !got.Document.Pinned { + t.Error("pinned = false for a read that named a revision") + } + if got.Document.Title != "Storage, first draft" { + t.Errorf("title = %q — the pin did not reach the older tree", got.Document.Title) + } +} + +// A ref name is not a revision this plane will serve. Without the guard, +// rev: "proposals/42" would hand back unreviewed proposal content as though it +// were approved — the one failure this service exists to prevent. +func TestRefNameRevIsRefused(t *testing.T) { + h := newHarness(t, false) + // A branch name, the approved branch itself, a full ref, an abbreviation + // that is unique today and may not be tomorrow, and an object name in the + // wrong case. + for _, rev := range []string{"proposals/42", "main", "refs/heads/main", "1111111", strings.Repeat("A", 40)} { + r := query(t, h, `{ document(space: "~bigbes/rfcs", id: "SPEC-0007", rev: "`+rev+`") { rev } }`) + if len(r.Errors) == 0 { + t.Errorf("rev %q was accepted: %s", rev, r.body) + continue + } + if !strings.Contains(r.errText(), "object name") { + t.Errorf("rev %q refused, but not for being a bad object name: %s", rev, r.errText()) + } + } +} + +// A revision that is well-formed but absent is absence, not a bad argument: the +// field is null and no error is reported. +func TestAbsentRevisionIsNull(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ document(space: "~bigbes/rfcs", id: "SPEC-0007", rev: "`+absentRev+`") { rev } }`) + + var got struct { + Document *struct{ Rev string } + } + ok(t, r, &got) + if got.Document != nil { + t.Errorf("document = %+v, want null", got.Document) + } +} + +// The addressing rule: a document with no usable id is addressed by its path, +// and an id two documents claim resolves to neither of them. +func TestAddressing(t *testing.T) { + h := newHarness(t, false) + + t.Run("path of a document with no frontmatter", func(t *testing.T) { + r := query(t, h, `{ document(space: "~bigbes/rfcs", id: "notes/plain") { id docId title } }`) + var got struct { + Document struct { + ID string + DocID *string + Title string + } + } + ok(t, r, &got) + if got.Document.ID != "notes/plain" { + t.Errorf("id = %q, want the path minus the extension", got.Document.ID) + } + if got.Document.DocID != nil { + t.Errorf("docId = %v, want null for a document with no frontmatter id", *got.Document.DocID) + } + }) + + t.Run("by path", func(t *testing.T) { + r := query(t, h, `{ document(space: "~bigbes/rfcs", path: "specs/0007-storage.md") { id } }`) + var got struct{ Document struct{ ID string } } + ok(t, r, &got) + if got.Document.ID != "SPEC-0007" { + t.Errorf("id = %q", got.Document.ID) + } + }) + + t.Run("a duplicated id resolves to neither document", func(t *testing.T) { + r := query(t, h, `{ document(space: "~bigbes/rfcs", id: "SPEC-0009") { id path } }`) + if len(r.Errors) == 0 { + t.Fatalf("a duplicated id resolved: %s", r.body) + } + if !strings.Contains(r.errText(), "claimed by 2 documents") { + t.Errorf("error does not name the collision: %s", r.errText()) + } + }) + + t.Run("both id and path", func(t *testing.T) { + r := query(t, h, `{ document(space: "~bigbes/rfcs", id: "SPEC-0007", path: "notes/plain.md") { id } }`) + if len(r.Errors) == 0 { + t.Fatalf("id and path together were accepted: %s", r.body) + } + }) + + t.Run("neither id nor path", func(t *testing.T) { + r := query(t, h, `{ document(space: "~bigbes/rfcs") { id } }`) + if len(r.Errors) == 0 { + t.Fatalf("an unaddressed document was accepted: %s", r.body) + } + }) +} + +// The listing is the same revision resolution, and carries every document. +func TestDocumentsListing(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ documents(space: "~bigbes/rfcs") { id rev pinned } }`) + + var got struct { + Documents []struct { + ID string + Rev string + Pinned bool + } + } + ok(t, r, &got) + if len(got.Documents) != len(headDocs) { + t.Fatalf("got %d documents, want %d", len(got.Documents), len(headDocs)) + } + for _, d := range got.Documents { + if d.Rev != headRev || d.Pinned { + t.Errorf("%s: rev/pinned = %q/%v", d.ID, d.Rev, d.Pinned) + } + } +} + +// ---- authorization -------------------------------------------------------- + +// The read plane is fail-closed: the owner and its agents read, and nobody +// else does. A refusal is a 401 with no content, never a page of login markup. +func TestAnonymousIsRefused(t *testing.T) { + h := newHarness(t, false) + + cases := map[string]func(*http.Request){ + "no credential": nil, + "a stranger's cookie": func(req *http.Request) { login(req, "somebody-else") }, + "an unknown token": func(req *http.Request) { + req.Header.Set("Authorization", "Bearer not-a-real-token") + }, + } + for name, auth := range cases { + t.Run(name, func(t *testing.T) { + r := post(t, h, `{ documents(space: "~bigbes/rfcs") { markdown } }`, auth) + if r.status != http.StatusUnauthorized { + t.Fatalf("status = %d, want 401; body %s", r.status, r.body) + } + if strings.Contains(r.body, "SPEC-0007") || strings.Contains(r.body, "authoritative") { + t.Fatalf("the refusal leaked content: %s", r.body) + } + }) + } +} + +// Introspection is content too, in the sense that matters here: it is served +// only to a caller with read authority. +func TestIntrospectionIsGated(t *testing.T) { + h := newHarness(t, false) + r := post(t, h, `{ __schema { queryType { name } } }`, nil) + if r.status != http.StatusUnauthorized { + t.Fatalf("anonymous introspection: status = %d, want 401", r.status) + } +} + +// An agent token reads. This is the other half of the ACL and the half the +// whole service is for. +func TestAgentTokenReads(t *testing.T) { + h := newHarness(t, false) + r := post(t, h, `{ document(space: "~bigbes/rfcs", id: "SPEC-0007") { title } }`, func(req *http.Request) { + req.Header.Set("Authorization", "Bearer "+agentTk) + }) + var got struct{ Document struct{ Title string } } + ok(t, r, &got) + if got.Document.Title != "Proposal storage model" { + t.Errorf("title = %q", got.Document.Title) + } +} + +// ---- search --------------------------------------------------------------- + +func TestSearchSpaceFiltering(t *testing.T) { + t.Run("a space list is the filter", func(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ + search(query: "storage", spaces: ["~bigbes/rfcs"]) { + total took hits { space id rev path title section lang score snippet } + } + }`) + var got struct { + Search struct { + Total int + Took string + Hits []struct { + Space, ID, Rev, Path, Title, Section, Lang, Snippet string + Score float64 + } + } + } + ok(t, r, &got) + + got_ := h.searcher.last.Spaces + if got_.Everything() || len(got_.Refs()) != 1 || got_.Refs()[0] != demoSpace { + t.Fatalf("query.Spaces = %s, want just %s", got_, demoSpace) + } + if h.searcher.last.Text != "storage" { + t.Errorf("query.Text = %q", h.searcher.last.Text) + } + if got.Search.Total != 1 || len(got.Search.Hits) != 1 { + t.Fatalf("total/hits = %d/%d", got.Search.Total, len(got.Search.Hits)) + } + hit := got.Search.Hits[0] + if hit.Space != "~bigbes/rfcs" || hit.Rev != headRev || hit.Path != "specs/0007-storage.md" { + t.Errorf("hit = %+v — a hit must be a pinned address", hit) + } + if !strings.Contains(hit.Snippet, "") { + t.Errorf("snippet lost its highlighting: %q", hit.Snippet) + } + }) + + t.Run("an omitted space list is every space", func(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ search(query: "storage") { total } }`) + ok(t, r, nil) + if !h.searcher.last.Spaces.Everything() { + t.Errorf("query.Spaces = %s, want the filter that excludes nothing", h.searcher.last.Spaces) + } + }) + + // The polarity trap, from the client's side: an empty project resolves to + // no spaces, and passing that membership to a search must return nothing + // rather than the whole corpus. null and [] are different arguments here, + // which is what makes the two expressible at all. + t.Run("an empty space list selects nothing", func(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ search(query: "storage", spaces: []) { total hits { id } } }`) + var got struct { + Search struct { + Total int + Hits []struct{ ID string } + } + } + ok(t, r, &got) + if got.Search.Total != 0 || len(got.Search.Hits) != 0 { + t.Fatalf("an empty space list matched %d/%d — it must select nothing", got.Search.Total, len(got.Search.Hits)) + } + if h.searcher.last.Spaces.Everything() || !h.searcher.last.Spaces.MatchesNothing() { + t.Errorf("query.Spaces = %s, want a filter selecting nothing", h.searcher.last.Spaces) + } + }) + + // End to end: what a client actually does with an empty project. + t.Run("an empty project searched through its membership returns no hits", func(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ project(owner: "bigbes", name: "fresh") { spaces { ref } } }`) + var project struct { + Project struct { + Spaces []struct{ Ref string } + } + } + ok(t, r, &project) + + refs := make([]string, 0, len(project.Project.Spaces)) + for _, s := range project.Project.Spaces { + refs = append(refs, `"`+s.Ref+`"`) + } + r = query(t, h, `{ search(query: "storage", spaces: [`+strings.Join(refs, ",")+`]) { total } }`) + var got struct{ Search struct{ Total int } } + ok(t, r, &got) + if got.Search.Total != 0 { + t.Fatalf("an empty project's search matched %d documents", got.Search.Total) + } + }) + + t.Run("limit and offset are passed through", func(t *testing.T) { + h := newHarness(t, false) + ok(t, query(t, h, `{ search(query: "storage", limit: 5, offset: 10) { total } }`), nil) + if h.searcher.last.Limit != 5 || h.searcher.last.Offset != 10 { + t.Errorf("limit/offset = %d/%d", h.searcher.last.Limit, h.searcher.last.Offset) + } + }) + + t.Run("a negative limit is refused", func(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ search(query: "storage", limit: -1) { total } }`) + if len(r.Errors) == 0 { + t.Fatalf("a negative limit was accepted: %s", r.body) + } + }) +} + +// ---- spaces and projects -------------------------------------------------- + +func TestSpaces(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ spaces { owner name ref created } }`) + + var got struct { + Spaces []struct { + Owner, Name, Ref string + Created time.Time + } + } + ok(t, r, &got) + if len(got.Spaces) != 2 { + t.Fatalf("got %d spaces", len(got.Spaces)) + } + if got.Spaces[0].Ref != "~bigbes/rfcs" || got.Spaces[0].Owner != "bigbes" || got.Spaces[0].Name != "rfcs" { + t.Errorf("space = %+v", got.Spaces[0]) + } + if !got.Spaces[0].Created.Equal(created) { + t.Errorf("created = %v", got.Spaces[0].Created) + } +} + +func TestSpaceApprovedRev(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ space(owner: "bigbes", name: "rfcs") { ref approvedRev } }`) + + var got struct { + Space struct{ Ref, ApprovedRev string } + } + ok(t, r, &got) + if got.Space.ApprovedRev != headRev { + t.Errorf("approvedRev = %q, want %q", got.Space.ApprovedRev, headRev) + } +} + +func TestAbsentSpaceIsNull(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ space(owner: "bigbes", name: "nope") { ref } }`) + var got struct{ Space *struct{ Ref string } } + ok(t, r, &got) + if got.Space != nil { + t.Errorf("space = %+v, want null", got.Space) + } +} + +func TestOwnerDecorationIsNotPartOfTheName(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ space(owner: "~bigbes", name: "rfcs") { ref } }`) + if len(r.Errors) == 0 { + t.Fatalf("a '~'-decorated owner was accepted: %s", r.body) + } +} + +func TestProjects(t *testing.T) { + h := newHarness(t, false) + + t.Run("a project lists its member spaces", func(t *testing.T) { + r := query(t, h, `{ project(owner: "bigbes", name: "docs") { ref meta spaces { ref } } }`) + var got struct { + Project struct { + Ref string + Meta bool + Spaces []struct{ Ref string } + } + } + ok(t, r, &got) + if got.Project.Ref != "~bigbes/+docs" || got.Project.Meta { + t.Errorf("project = %+v", got.Project) + } + if len(got.Project.Spaces) != 1 || got.Project.Spaces[0].Ref != "~bigbes/rfcs" { + t.Errorf("spaces = %+v", got.Project.Spaces) + } + }) + + // A project is a saved filter, and a filter with no terms selects nothing. + // Collapsing that into "everything" would turn a freshly created project + // into the whole corpus — invisibly, and the opposite of what its author + // asked for. + t.Run("an empty project selects nothing", func(t *testing.T) { + r := query(t, h, `{ project(owner: "bigbes", name: "fresh") { ref spaces { ref } } }`) + var got struct { + Project struct { + Ref string + Spaces []struct{ Ref string } + } + } + ok(t, r, &got) + if len(got.Project.Spaces) != 0 { + t.Fatalf("an empty project resolved to %d spaces: %+v", len(got.Project.Spaces), got.Project.Spaces) + } + }) + + // The meta-project is an address that resolves to a filter, not a row: it + // has no membership to be missing and cannot be looked up. + t.Run("the meta-project resolves without a row", func(t *testing.T) { + r := query(t, h, `{ project(owner: "bigbes", name: "everything") { ref meta spaces { ref } } }`) + var got struct { + Project struct { + Ref string + Meta bool + Spaces []struct{ Ref string } + } + } + ok(t, r, &got) + if got.Project.Ref != "~bigbes/+everything" || !got.Project.Meta { + t.Errorf("meta-project = %+v", got.Project) + } + if len(got.Project.Spaces) != 2 { + t.Errorf("the meta-project lists %d spaces, want every space", len(got.Project.Spaces)) + } + }) + + t.Run("an absent project is null", func(t *testing.T) { + r := query(t, h, `{ project(owner: "bigbes", name: "nope") { ref } }`) + var got struct{ Project *struct{ Ref string } } + ok(t, r, &got) + if got.Project != nil { + t.Errorf("project = %+v, want null", got.Project) + } + }) + + // The listing is rows only. The meta-project is not one, which is what + // makes it impossible to rename, delete or forget to keep in step. + t.Run("the listing carries only stored projects", func(t *testing.T) { + r := query(t, h, `{ projects { ref meta } }`) + var got struct { + Projects []struct { + Ref string + Meta bool + } + } + ok(t, r, &got) + if len(got.Projects) != 2 { + t.Fatalf("got %d projects", len(got.Projects)) + } + for _, p := range got.Projects { + if p.Meta { + t.Errorf("%s is listed as the meta-project", p.Ref) + } + } + }) +} + +// ---- proposals ------------------------------------------------------------ + +func TestProposals(t *testing.T) { + h := newHarness(t, true) + merged := created.Add(time.Hour) + h.proposals.rows = []Proposal{ + { + ID: 42, Space: demoSpace, Title: "Rewrite the storage model", + Rationale: "because", BaseRev: headRev, Branch: "proposals/42", + State: core.StateOpen, Agent: "claude-code/spec-writer", + AgentSession: "session-1", Created: created, + }, + { + ID: 43, Space: demoSpace, Title: "Already landed", + BaseRev: headRev, Branch: "proposals/43", State: core.StateMerged, + Approval: core.ApprovalPolicy, MergedRev: oldRev, + Agent: "claude-code/spec-writer", AgentSession: "session-2", + Created: created, Resolved: &merged, + }, + } + + t.Run("open", func(t *testing.T) { + r := query(t, h, `{ + proposals(space: "~bigbes/rfcs", state: OPEN) { + id space title rationale baseRev branch state approval mergedRev agent agentSession created resolved + } + }`) + var got struct { + Proposals []struct { + ID int + Space, Title, Rationale, BaseRev string + Branch, State string + Approval, MergedRev *string + Agent, AgentSession string + Created time.Time + Resolved *time.Time + } + } + ok(t, r, &got) + if len(got.Proposals) != 1 { + t.Fatalf("got %d open proposals", len(got.Proposals)) + } + p := got.Proposals[0] + if p.ID != 42 || p.State != "OPEN" || p.Branch != "proposals/42" { + t.Errorf("proposal = %+v", p) + } + // An unmerged proposal has no approval and no merge commit, and must + // not be reported as though it had either. + if p.Approval != nil || p.MergedRev != nil || p.Resolved != nil { + t.Errorf("an open proposal reported approval=%v mergedRev=%v resolved=%v", p.Approval, p.MergedRev, p.Resolved) + } + }) + + // Auto-merged is not human-approved, and a reader must be able to tell. + t.Run("merged carries how it was approved", func(t *testing.T) { + r := query(t, h, `{ proposals(space: "~bigbes/rfcs", state: MERGED) { id state approval mergedRev resolved } }`) + var got struct { + Proposals []struct { + ID int + State string + Approval, MergedRev *string + Resolved *time.Time + } + } + ok(t, r, &got) + if len(got.Proposals) != 1 { + t.Fatalf("got %d merged proposals", len(got.Proposals)) + } + p := got.Proposals[0] + if p.Approval == nil || *p.Approval != "POLICY" { + t.Errorf("approval = %v, want POLICY", p.Approval) + } + if p.MergedRev == nil || *p.MergedRev != oldRev || p.Resolved == nil { + t.Errorf("mergedRev/resolved = %v/%v", p.MergedRev, p.Resolved) + } + }) + + // Nothing implements the port yet. The field says so rather than answering + // "no proposals", which would tell a reviewer their queue is clear when it + // is merely unread. + t.Run("unwired", func(t *testing.T) { + bare := newHarness(t, false) + r := query(t, bare, `{ proposals(space: "~bigbes/rfcs", state: OPEN) { id } }`) + if len(r.Errors) == 0 { + t.Fatalf("an unwired proposal listing answered: %s", r.body) + } + if !strings.Contains(r.errText(), "no proposal listing") { + t.Errorf("error does not say what is missing: %s", r.errText()) + } + }) +} + +// ---- the schema itself ---------------------------------------------------- + +// There are no mutations, deliberately: the write plane's `If-Match` +// concurrency is an HTTP idiom, and a federated type is a consumed contract, so +// the proposal types stay off this surface until they stop moving. A mutation +// appearing here is a design change and should fail this test first. +func TestSchemaHasNoMutations(t *testing.T) { + h := newHarness(t, false) + r := query(t, h, `{ __schema { mutationType { name } subscriptionType { name } } }`) + var got struct { + Schema struct { + MutationType *struct{ Name string } + SubscriptionType *struct{ Name string } + } `json:"__schema"` + } + ok(t, r, &got) + if got.Schema.MutationType != nil { + t.Errorf("the schema declares a mutation type %q", got.Schema.MutationType.Name) + } + if got.Schema.SubscriptionType != nil { + t.Errorf("the schema declares a subscription type %q", got.Schema.SubscriptionType.Name) + } +} + +// The mounting call the package documents, exercised: a chi router with no +// middleware of its own, the endpoint at /query, and a query that goes through. +// The daemon's one line is the line under test here. +func TestMountedOnAChiRouter(t *testing.T) { + resolver, err := authn.NewResolver("bigbes", stubTokenStore{}) + if err != nil { + t.Fatalf("NewResolver: %v", err) + } + srv, err := New(Options{Reader: newFakeReader(), Searcher: &fakeSearcher{}, Resolver: resolver}) + if err != nil { + t.Fatalf("New: %v", err) + } + router := chi.NewRouter() + router.Handle("/query", srv.Handler()) + + h := harness{handler: router} + var got struct{ Space struct{ Ref string } } + ok(t, query(t, h, `{ space(owner: "bigbes", name: "rfcs") { ref } }`), &got) + if got.Space.Ref != "~bigbes/rfcs" { + t.Errorf("ref = %q", got.Space.Ref) + } + + // And the gate is still in front of it once mounted. + if r := post(t, h, `{ spaces { ref } }`, nil); r.status != http.StatusUnauthorized { + t.Errorf("anonymous request through the router: status = %d, want 401", r.status) + } +} + +// New refuses a half-wired server at startup rather than failing inside the +// first query. +func TestNewRequiresItsSeams(t *testing.T) { + resolver, err := authn.NewResolver("bigbes", stubTokenStore{}) + if err != nil { + t.Fatalf("NewResolver: %v", err) + } + cases := map[string]Options{ + "no reader": {Searcher: &fakeSearcher{}, Resolver: resolver}, + "no searcher": {Reader: newFakeReader(), Resolver: resolver}, + "no resolver": {Reader: newFakeReader(), Searcher: &fakeSearcher{}}, + } + for name, opts := range cases { + if _, err := New(opts); err == nil { + t.Errorf("%s: New succeeded", name) + } + } +} diff --git a/graph/model/models.go b/graph/model/models.go new file mode 100644 index 0000000000000000000000000000000000000000..0cbb43c61b54a766ebc249225effe2b25e35893f --- /dev/null +++ b/graph/model/models.go @@ -0,0 +1,95 @@ +// Package model holds the Go types the GraphQL schema binds to. +// +// They are hand-written rather than generated so that the wire shape is +// reviewable in one file, and they are deliberately their own types rather than +// aliases of service/'s: a GraphQL type is a published contract, and binding it +// straight onto an internal struct means every field added below the API layer +// appears in the schema by accident. +// +// Fields gqlgen resolves with a call rather than a struct read — Space.approvedRev, +// Project.spaces — are absent here on purpose. Their absence is what makes gqlgen +// generate a resolver for them, so the repository is only opened, and the +// membership only listed, when a query actually asks. +package model + +import "time" + +// Space is one space: a bare git repository addressed ~owner/name. +type Space struct { + Owner string + Name string + Ref string + Created time.Time +} + +// Document is one document at one revision. +// +// The optional frontmatter fields are plain strings, with the empty string +// meaning "the frontmatter does not carry this key". DocID is the exception and +// is a pointer, because there the distinction is load-bearing: a null DocID is +// exactly the case where ID fell back to the document's path, which is what an +// agent about to propose an edit has to know. +type Document struct { + Space string + ID string + DocID *string + Path string + Rev string + Blob string + Pinned bool + Title string + Status string + Section string + Summary string + Type string + Supersedes string + Tags []string + Owners []string + Markdown string +} + +// Project is one project: a saved filter over the one global index. +type Project struct { + Owner string + Name string + Ref string + Meta bool +} + +// SearchResults is one page of ranked hits. +type SearchResults struct { + Total int + Took string + Hits []*SearchHit +} + +// SearchHit is one ranked document. +type SearchHit struct { + Space string + ID string + Rev string + Path string + Anchor string + Title string + Section string + Lang string + Score float64 + Snippet string +} + +// Proposal is one proposal as the read schema reports it. +type Proposal struct { + ID int + Space string + Title string + Rationale string + BaseRev string + Branch string + State ProposalState + Approval *Approval + MergedRev *string + Agent string + AgentSession string + Created time.Time + Resolved *time.Time +} diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go new file mode 100644 index 0000000000000000000000000000000000000000..4cebcfdcbaa423a95391541ccccad8822f1d01d7 --- /dev/null +++ b/graph/model/models_gen.go @@ -0,0 +1,99 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package model + +import ( + "fmt" + "io" + "strconv" +) + +// How a merge was authorized. Auto-merged is not human-approved, and readers must +// be able to tell: a bot asking for the approved text of a spec should be able to +// require human approval and get a different answer than for a firehose note. +type Approval string + +const ( + ApprovalHuman Approval = "HUMAN" + ApprovalPolicy Approval = "POLICY" +) + +var AllApproval = []Approval{ + ApprovalHuman, + ApprovalPolicy, +} + +func (e Approval) IsValid() bool { + switch e { + case ApprovalHuman, ApprovalPolicy: + return true + } + return false +} + +func (e Approval) String() string { + return string(e) +} + +func (e *Approval) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Approval(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Approval", str) + } + return nil +} + +func (e Approval) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// The lifecycle of a proposal. Collapsed from the usual five states because there +// is exactly one reviewer: "approve" is "merge now", and a proposal you dislike is +// rejected rather than sent back for changes. +type ProposalState string + +const ( + ProposalStateOpen ProposalState = "OPEN" + ProposalStateMerged ProposalState = "MERGED" + ProposalStateRejected ProposalState = "REJECTED" +) + +var AllProposalState = []ProposalState{ + ProposalStateOpen, + ProposalStateMerged, + ProposalStateRejected, +} + +func (e ProposalState) IsValid() bool { + switch e { + case ProposalStateOpen, ProposalStateMerged, ProposalStateRejected: + return true + } + return false +} + +func (e ProposalState) String() string { + return string(e) +} + +func (e *ProposalState) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ProposalState(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ProposalState", str) + } + return nil +} + +func (e ProposalState) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/graph/resolver.go b/graph/resolver.go new file mode 100644 index 0000000000000000000000000000000000000000..4e517ca74b0c7c958c47fc1e619f3c8cecbed796 --- /dev/null +++ b/graph/resolver.go @@ -0,0 +1,106 @@ +package graph + +import ( + "context" + "time" + + "sourcecraft.dev/bigbes/sr-ht-spec/core" + "sourcecraft.dev/bigbes/sr-ht-spec/doc" + "sourcecraft.dev/bigbes/sr-ht-spec/search" + "sourcecraft.dev/bigbes/sr-ht-spec/service" +) + +// Reader is the part of the orchestration layer this schema reads through. +// *service.Service satisfies it. +// +// It is declared the way mcpsrv/ and web/ declare theirs, and every method is +// one service/ already has: the design's "MCP and GraphQL are not competitors — +// the MCP tools call the same resolver layer, not a parallel implementation" is +// only true if all three surfaces call the same functions. A method here that +// service/ does not have would be the beginning of a second implementation, and +// a rule this schema resolved for itself would be a rule the other two could +// disagree with. +type Reader interface { + ListSpaces(ctx context.Context) ([]*service.Space, error) + OpenSpace(ctx context.Context, ref core.SpaceRef) (*service.Space, error) + ResolveRev(ctx context.Context, sp *service.Space, rev string) (string, error) + + // Archive is the whole of the document read path here: the addressing rule + // — a document is named by its frontmatter id when that is well-formed and + // unique in the space, and by its path otherwise — lives in doc/ behind a + // constructor that takes git objects, so a surface that resolved ids for + // itself would either reach past service/ into gitx or keep a second copy + // of the rule. Neither is allowed to happen a third time. + Archive(ctx context.Context, sp *service.Space, rev string) (*doc.Archive, map[string][]byte, error) + + GetProject(ctx context.Context, ref core.ProjectRef) (*service.Project, error) + ListProjects(ctx context.Context) ([]*service.Project, error) + + // ProjectSpaces is the listing counterpart of service.ResolveProject, and + // the difference is not cosmetic: a filter is never enumerated, whereas a + // list is enumerated by definition. The meta-project therefore lists every + // space here — a snapshot of the corpus as of the call — while a query + // restricted to it must go through the filter, which excludes nothing and + // so cannot go stale. + ProjectSpaces(ctx context.Context, ref core.ProjectRef) ([]*service.Space, error) +} + +// Searcher is the query side of the one global index. *search.Index satisfies +// it. +type Searcher interface { + Search(ctx context.Context, q search.Query) (search.Results, error) +} + +// Proposal is one proposal as the read schema needs it: service/-shaped, in +// core types, so the port below stays free of anything GraphQL. +type Proposal struct { + ID int + Space core.SpaceRef + Title string + Rationale string + BaseRev string + Branch string + State core.ProposalState + Approval core.Approval + MergedRev string + Agent string + AgentSession string + Created time.Time + Resolved *time.Time +} + +// Proposals is the read side of the proposal store. +// +// It is a port with no production implementation yet, and that is a real gap +// rather than a design choice of this package: the design puts "proposal +// listing" in Phase 2's read schema, but service/ exposes no proposal read at +// all, and db/'s only listing is by state across every space. Nothing above +// service/ may touch db/ directly — that rule is what keeps the three +// agent-facing surfaces behaviourally identical — so this schema declares what +// it needs and waits for service/ to supply it. +// +// Until then Options.Proposals is nil and the `proposals` field fails loudly +// with that explanation. It does not return an empty list: "this space has no +// open proposals" and "this build cannot answer the question" are different +// answers, and quietly giving the first would tell a reviewer their queue is +// clear when it is unread. +type Proposals interface { + ListProposals(ctx context.Context, space core.SpaceRef, state core.ProposalState) ([]Proposal, error) +} + +// Compile-time assertions that the production types satisfy the interfaces this +// package is written against. They are here rather than in a test so that a +// signature change in service/ or search/ breaks the build of the package that +// depends on them, not of a test somebody may not run. +var ( + _ Reader = (*service.Service)(nil) + _ Searcher = (*search.Index)(nil) +) + +// Resolver is the root resolver. It holds only the seams above; every field of +// the schema is answered by calling through them. +type Resolver struct { + reader Reader + searcher Searcher + proposals Proposals +} diff --git a/graph/schema.graphqls b/graph/schema.graphqls new file mode 100644 index 0000000000000000000000000000000000000000..616a19b740d84939e41ec2e3ef77e9ef8d225751 --- /dev/null +++ b/graph/schema.graphqls @@ -0,0 +1,294 @@ +# spec.sr.ht — the read schema. +# +# There are no mutations here and that is the design's decision, not an +# omission: the write plane's concurrency story is `If-Match: `, an +# HTTP idiom with well-defined 409 semantics that agents get right by default, +# and modelling base-rev as a mutation argument is a contract worth designing +# once, after the proposal state machine has stopped moving. Federated types are +# consumed contracts, so churning the proposal types here would be expensive. +# +# Everything this schema serves goes through service/ — the same functions the +# REST, MCP and web surfaces call — so the three agent-facing surfaces cannot +# disagree about what a document is or which revision is approved. + +""" +An RFC-3339 timestamp. +""" +scalar Time + +""" +The lifecycle of a proposal. Collapsed from the usual five states because there +is exactly one reviewer: "approve" is "merge now", and a proposal you dislike is +rejected rather than sent back for changes. +""" +enum ProposalState { + OPEN + MERGED + REJECTED +} + +""" +How a merge was authorized. Auto-merged is not human-approved, and readers must +be able to tell: a bot asking for the approved text of a spec should be able to +require human approval and get a different answer than for a firehose note. +""" +enum Approval { + HUMAN + POLICY +} + +type Query { + """ + Every space on the instance, ordered by owner then name. There is one human + here and no visibility levels, so there is nothing to filter: the list is the + whole corpus. + """ + spaces: [Space!]! + + """ + One space by reference. `owner` carries no leading '~' — that is routing + decoration, never part of the stored name. Null when there is no such space. + """ + space(owner: String!, name: String!): Space + + """ + One document of a space. + + Exactly one of `id` and `path` must be given. `id` is the document's address + under the design's rule: its frontmatter `id:` when that is well-formed and + unique in the space, and otherwise its path without the ".md" extension. An id + claimed by two documents resolves to neither — refusing to guess is the only + safe answer, since silently picking one would make links point at a document + the author did not mean. + + `rev` pins the read to an immutable revision and must be a full 40-character + object name; omit it to read the space's approved head, which is the default + because serving drafts by default would poison every downstream agent context + with unreviewed text. Ref names are refused, so there is no `rev` that makes + this field serve an unreviewed proposal branch. + + Null when the space, the revision or the document is absent. + """ + document(space: String!, id: String, path: String, rev: String): Document + + """ + Every document of a space at a revision, in tree order. `rev` follows the same + rule as on `document`. + """ + documents(space: String!, rev: String): [Document!]! + + """ + Keyword search over the one global index. + + `spaces` is the project filter: a project is a saved filter over this index, + not a container, so searching a project means passing its member spaces here. + + Omitting the argument searches every space — that is the meta-project, a + filter that excludes nothing. Passing a list searches exactly those spaces, + and passing an *empty* list therefore searches nothing at all, which is what + an empty project's membership means. The two are different arguments here on + purpose: null and [] are distinct in GraphQL, so a client that resolved a + project to zero spaces cannot be handed the whole corpus by accident. + + An empty `query` returns no hits rather than every document: "search for + nothing" is a caller that has not collected its input yet. + """ + search(query: String!, spaces: [String!], limit: Int, offset: Int): SearchResults! + + """ + Every stored project, ordered by owner then name. The meta-project is not in + this list because it is not a row; it is an address that resolves to a filter, + and `project(owner: ..., name: "everything")` returns it. + """ + projects: [Project!]! + + """ + One project by reference. `name` carries no leading '+'. Null when there is no + such project. + """ + project(owner: String!, name: String!): Project + + """ + A space's proposals in one state, newest first. + + `state` is required. The proposal store lists by state, and an optional + argument would need an "every state" meaning for its absent case — the same + empty-means-everything polarity this schema refuses on `search(spaces:)`. Ask + for the states you want, with aliases if you want more than one. + + This is a read: opening, merging and rejecting proposals are write-plane + operations and live on REST and MCP. + """ + proposals(space: String!, state: ProposalState!): [Proposal!]! +} + +""" +A space: one bare git repository, addressed `~owner/name`. It is the unit of +ownership, ACL and review policy. +""" +type Space { + """The owning user, with no leading '~'.""" + owner: String! + name: String! + """The canonical reference, "~owner/name".""" + ref: String! + created: Time! + """ + The current tip of the approved branch, as a full object name. This is the + value to pin a later read to, and the value the write plane takes as + `If-Match`. Resolving it opens the space's repository, so it is only paid for + when it is asked for. + """ + approvedRev: String! +} + +""" +A markdown document with YAML frontmatter, at one revision. A document reachable +from the approved ref is approved: approval is a property of the branch, never +of the frontmatter, which is why there is no "approved" field here and no +"approved" value in `status`. +""" +type Document { + """The space this document belongs to, "~owner/name".""" + space: String! + """ + How this document is addressed: its frontmatter id when that is well-formed + and unique in the space, and its path without the extension otherwise. + """ + id: String! + """ + The frontmatter `id:`, when the document has a well-formed one. Null when it + is absent or malformed. + + It is not always the same as `id`: an id two documents claim resolves to + neither of them, so `id` falls back to the path there as well. `id != docId` + is precisely the set of documents that cannot be addressed by their id, which + is what an agent about to propose an edit needs to know. + """ + docId: String + """The document's path in the tree, extension included.""" + path: String! + """The commit this content was read at. Immutable: pass it back as `rev`.""" + rev: String! + """The sha of this document's content. Changes only when the content does.""" + blob: String! + """ + Whether the caller named the revision. False means this is the approved head + as of this call — the reviewed, canonical text. + """ + pinned: Boolean! + """ + The document's title: its frontmatter `title:`, then its first `# heading`, + then its file name. Never empty — the chain is what keeps an untitled document + nameable rather than reported as blank. + """ + title: String! + """ + The authored lifecycle marker (draft, review, superseded). It is not approval + state. Empty when the frontmatter does not carry the key. + """ + status: String! + """The top-level directory the document lives under ("specs", "notes").""" + section: String! + """Authored metadata. Empty when the frontmatter does not carry the key.""" + summary: String! + type: String! + supersedes: String! + tags: [String!]! + owners: [String!]! + """The whole document, frontmatter included, exactly as stored.""" + markdown: String! +} + +""" +A project: a named set of spaces sharing one search scope, one MCP view and one +wikilink namespace. + +A project is pure metadata — a saved filter, not a container. It owns no index +and no storage, which is why it has no revision and no documents of its own. +""" +type Project { + """The owning user, with no leading '~'.""" + owner: String! + """The project name, with no leading '+'.""" + name: String! + """The canonical reference, "~owner/+name".""" + ref: String! + """ + Whether this is the meta-project: the degenerate filter that excludes nothing. + Its `spaces` is therefore every space as of this call rather than a stored + membership — a snapshot, which is why a query restricted to a project should + be built from the filter and not from a frozen list of names. + """ + meta: Boolean! + """ + The member spaces, ordered by owner then name. Empty for a project that + selects nothing, which is what a project with no members means. + """ + spaces: [Space!]! +} + +"""One page of ranked hits.""" +type SearchResults { + """How many documents matched, not how many were returned.""" + total: Int! + """How long the query took, as a Go duration string.""" + took: String! + hits: [SearchHit!]! +} + +""" +One ranked document. `space`, `path`, `rev` and `anchor` together are a pinned, +immutable address for the result. +""" +type SearchHit { + space: String! + """The document's address within its space, as `Document.id` reports it.""" + id: String! + rev: String! + path: String! + """The heading anchor within `path`, set for one entry of an activity log.""" + anchor: String! + title: String! + section: String! + """The language the document was indexed as ("en", "ru").""" + lang: String! + score: Float! + """ + A fragment of the matching text with the matched terms wrapped in ``. + Everything around them is HTML-escaped by the index, so this is HTML: render + it as HTML or strip the tags, but do not escape it again. + """ + snippet: String! +} + +""" +A bundle of document edits awaiting review: a branch `proposals/` plus a +row. Proposals are read-only here; they are opened over REST and MCP. +""" +type Proposal { + id: Int! + """The space the proposal is against, "~owner/name".""" + space: String! + title: String! + rationale: String! + """ + The approved-head sha the agent had read when it opened the proposal. It does + not move as the proposal accumulates edits. + """ + baseRev: String! + """The branch carrying the edits, "proposals/".""" + branch: String! + state: ProposalState! + """How the merge was authorized. Null until the proposal has merged.""" + approval: Approval + """The merge commit. Null until the proposal has merged.""" + mergedRev: String + """The agent identity that opened it, e.g. "claude-code/spec-writer".""" + agent: String! + """The agent's session id.""" + agentSession: String! + created: Time! + """When the proposal left the open state. Null while it is still open.""" + resolved: Time +} diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go new file mode 100644 index 0000000000000000000000000000000000000000..bff697a5eab72e2659bb41a023f8da9730ba3be5 --- /dev/null +++ b/graph/schema.resolvers.go @@ -0,0 +1,448 @@ +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.36 + +import ( + "context" + "errors" + "fmt" + "strings" + + "sourcecraft.dev/bigbes/sr-ht-spec/core" + "sourcecraft.dev/bigbes/sr-ht-spec/doc" + "sourcecraft.dev/bigbes/sr-ht-spec/graph/api" + "sourcecraft.dev/bigbes/sr-ht-spec/graph/model" + "sourcecraft.dev/bigbes/sr-ht-spec/search" + "sourcecraft.dev/bigbes/sr-ht-spec/service" +) + +// Spaces is the resolver for the spaces field. +func (r *projectResolver) Spaces(ctx context.Context, obj *model.Project) ([]*model.Space, error) { + ref := core.ProjectRef{Owner: obj.Owner, Name: obj.Name} + spaces, err := r.reader.ProjectSpaces(ctx, ref) + if err != nil { + return nil, err + } + return spaceModels(spaces), nil +} + +// Spaces is the resolver for the spaces field. +func (r *queryResolver) Spaces(ctx context.Context) ([]*model.Space, error) { + spaces, err := r.reader.ListSpaces(ctx) + if err != nil { + return nil, err + } + return spaceModels(spaces), nil +} + +// Space is the resolver for the space field. +func (r *queryResolver) Space(ctx context.Context, owner string, name string) (*model.Space, error) { + ref, err := spaceRef(owner, name) + if err != nil { + return nil, err + } + sp, err := r.reader.OpenSpace(ctx, ref) + if err != nil { + return nil, orNull(err) + } + return spaceModel(sp), nil +} + +// Document is the resolver for the document field. +func (r *queryResolver) Document(ctx context.Context, space string, id *string, path *string, rev *string) (*model.Document, error) { + arc, bodies, resolved, pinned, err := r.archive(ctx, space, rev) + if err != nil { + return nil, orNull(err) + } + page, found, err := address(arc, deref(id), deref(path)) + if err != nil || !found { + return nil, err + } + body, ok := bodies[page.Path] + if !ok { + // The archive is built from these very bodies, so a page without one is + // a broken invariant rather than a missing document. Reporting an empty + // markdown field would be indistinguishable from an empty document. + return nil, fmt.Errorf("document %s of %s at %s has no body", page.Path, arc.Space, resolved) + } + return documentModel(arc.Space, resolved, pinned, page, body), nil +} + +// Documents is the resolver for the documents field. +func (r *queryResolver) Documents(ctx context.Context, space string, rev *string) ([]*model.Document, error) { + arc, bodies, resolved, pinned, err := r.archive(ctx, space, rev) + if err != nil { + return nil, err + } + pages := arc.All() + out := make([]*model.Document, 0, len(pages)) + for _, page := range pages { + body, ok := bodies[page.Path] + if !ok { + return nil, fmt.Errorf("document %s of %s at %s has no body", page.Path, arc.Space, resolved) + } + out = append(out, documentModel(arc.Space, resolved, pinned, page, body)) + } + return out, nil +} + +// Search is the resolver for the search field. +func (r *queryResolver) Search(ctx context.Context, query string, spaces []string, limit *int, offset *int) (*model.SearchResults, error) { + q := search.Query{Text: strings.TrimSpace(query)} + + // Filter polarity, which is the one thing here that is dangerous to get + // wrong — and the reason core.SpaceFilter exists rather than a slice. + // Absent means every space, which is the meta-project. A list means exactly + // those spaces, and a list that is present but empty therefore selects + // nothing at all: that is what an empty project's membership is, and a + // client passing one through must get no hits rather than the whole corpus. + // GraphQL distinguishes the two cases for free — null is not [] — so the + // argument's own shape carries the polarity that used to be a convention. + if spaces == nil { + q.Spaces = core.EverythingFilter() + } else { + refs := make([]core.SpaceRef, 0, len(spaces)) + for _, s := range spaces { + ref, err := core.ParseSpaceRef(strings.TrimSpace(s)) + if err != nil { + return nil, fmt.Errorf("spaces: %w", err) + } + refs = append(refs, ref) + } + q.Spaces = core.SpacesFilter(refs, nil) + } + + if limit != nil { + if *limit < 0 { + return nil, fmt.Errorf("limit: %d is negative", *limit) + } + q.Limit = *limit + } + if offset != nil { + if *offset < 0 { + return nil, fmt.Errorf("offset: %d is negative", *offset) + } + q.Offset = *offset + } + + res, err := r.searcher.Search(ctx, q) + if err != nil { + return nil, err + } + out := &model.SearchResults{ + Total: int(res.Total), + Took: res.Took.String(), + Hits: make([]*model.SearchHit, 0, len(res.Hits)), + } + for _, h := range res.Hits { + out.Hits = append(out.Hits, &model.SearchHit{ + Space: h.Space.String(), + ID: h.ID, + Rev: h.Rev, + Path: h.Path, + Anchor: h.Anchor, + Title: h.Title, + Section: h.Section, + Lang: string(h.Lang), + Score: h.Score, + Snippet: h.Snippet, + }) + } + return out, nil +} + +// Projects is the resolver for the projects field. +func (r *queryResolver) Projects(ctx context.Context) ([]*model.Project, error) { + projects, err := r.reader.ListProjects(ctx) + if err != nil { + return nil, err + } + out := make([]*model.Project, 0, len(projects)) + for _, p := range projects { + out = append(out, projectModel(p.Ref)) + } + return out, nil +} + +// Project is the resolver for the project field. +func (r *queryResolver) Project(ctx context.Context, owner string, name string) (*model.Project, error) { + ref, err := projectRef(owner, name) + if err != nil { + return nil, err + } + // The meta-project is an address that resolves to a filter, not a row: it + // needs no storage, cannot be renamed or deleted, and adding a space to the + // service adds it to the meta-project by construction. So it is answered + // here rather than looked up — a lookup would report the one project that + // can never be missing as missing. + if ref.IsMeta() { + return projectModel(ref), nil + } + if _, err := r.reader.GetProject(ctx, ref); err != nil { + return nil, orNull(err) + } + return projectModel(ref), nil +} + +// Proposals is the resolver for the proposals field. +func (r *queryResolver) Proposals(ctx context.Context, space string, state model.ProposalState) ([]*model.Proposal, error) { + ref, err := core.ParseSpaceRef(strings.TrimSpace(space)) + if err != nil { + return nil, fmt.Errorf("space: %w", err) + } + // GraphQL has already validated the enum, so this cannot fail over a + // caller's spelling; it fails only if this schema and core disagree about + // the state machine, which is worth hearing about rather than defaulting + // past. + st, err := core.ParseProposalState(strings.ToLower(string(state))) + if err != nil { + return nil, err + } + if r.proposals == nil { + return nil, errors.New("proposals cannot be read: service/ exposes no proposal listing yet, " + + "and nothing above it may query the database directly (the write plane is Phase 3)") + } + proposals, err := r.proposals.ListProposals(ctx, ref, st) + if err != nil { + return nil, err + } + out := make([]*model.Proposal, 0, len(proposals)) + for _, p := range proposals { + m, err := proposalModel(p) + if err != nil { + return nil, err + } + out = append(out, m) + } + return out, nil +} + +// ApprovedRev is the resolver for the approvedRev field. +func (r *spaceResolver) ApprovedRev(ctx context.Context, obj *model.Space) (string, error) { + // A field resolver rather than a struct field: ListSpaces deliberately does + // not open repositories, so resolving the approved head of every space in a + // listing would make the cheapest view in the service the most expensive + // one. Here it is paid for only by a query that asks for it. + sp, err := r.reader.OpenSpace(ctx, core.SpaceRef{Owner: obj.Owner, Name: obj.Name}) + if err != nil { + return "", err + } + return r.reader.ResolveRev(ctx, sp, service.ApprovedRev) +} + +// Project returns api.ProjectResolver implementation. +func (r *Resolver) Project() api.ProjectResolver { return &projectResolver{r} } + +// Query returns api.QueryResolver implementation. +func (r *Resolver) Query() api.QueryResolver { return &queryResolver{r} } + +// Space returns api.SpaceResolver implementation. +func (r *Resolver) Space() api.SpaceResolver { return &spaceResolver{r} } + +type projectResolver struct{ *Resolver } +type queryResolver struct{ *Resolver } +type spaceResolver struct{ *Resolver } + +// !!! WARNING !!! +// The code below was going to be deleted when updating resolvers. It has been copied here so you have +// one last chance to move it out of harms way if you want. There are two reasons this happens: +// - When renaming or deleting a resolver the old code will be put in here. You can safely delete +// it when you're done. +// - You have helper methods in this file. Move them out to keep these resolver files clean. +func (r *queryResolver) archive(ctx context.Context, space string, rev *string) (*doc.Archive, map[string][]byte, string, bool, error) { + ref, err := core.ParseSpaceRef(strings.TrimSpace(space)) + if err != nil { + return nil, nil, "", false, fmt.Errorf("space: %w", err) + } + want := deref(rev) + if err := service.ValidateReadRev(want); err != nil { + return nil, nil, "", false, fmt.Errorf("rev: %w", err) + } + sp, err := r.reader.OpenSpace(ctx, ref) + if err != nil { + return nil, nil, "", false, err + } + arc, bodies, err := r.reader.Archive(ctx, sp, want) + if err != nil { + return nil, nil, "", false, err + } + return arc, bodies, arc.Rev, want != service.ApprovedRev, nil +} +func address(arc *doc.Archive, id, path string) (*doc.Page, bool, error) { + id = strings.TrimSpace(id) + path = strings.TrimSpace(path) + + switch { + case id == "" && path == "": + return nil, false, errors.New("give either id or path: a document has to be addressed") + case id != "" && path != "": + return nil, false, fmt.Errorf("give either id or path, not both: %q and %q cannot both name the document wanted", id, path) + } + + if path != "" { + if err := core.ValidateDocPath(path); err != nil { + return nil, false, fmt.Errorf("path: %w", err) + } + page, ok := arc.ByPath(path) + return page, ok, nil + } + + if page, ok := arc.Page(id); ok { + return page, true, nil + } + + // Nothing is addressed by that id. Saying only "no such document" would + // hide the one case a caller cannot otherwise diagnose: an id two documents + // claim resolves to neither of them, and the collision is invisible from + // outside the space. + var claimed []string + for _, p := range arc.All() { + if p.DocID == id { + claimed = append(claimed, p.Path) + } + } + if len(claimed) > 1 { + return nil, false, fmt.Errorf("id: %q is claimed by %d documents (%s) and resolves to none of them; address one of them by path instead", + id, len(claimed), strings.Join(claimed, ", ")) + } + return nil, false, nil +} +func spaceModel(sp *service.Space) *model.Space { + return &model.Space{ + Owner: sp.Ref.Owner, + Name: sp.Ref.Name, + Ref: sp.Ref.String(), + Created: sp.Created, + } +} +func spaceModels(spaces []*service.Space) []*model.Space { + out := make([]*model.Space, 0, len(spaces)) + for _, sp := range spaces { + out = append(out, spaceModel(sp)) + } + return out +} +func projectModel(ref core.ProjectRef) *model.Project { + return &model.Project{ + Owner: ref.Owner, + Name: ref.Name, + Ref: ref.String(), + Meta: ref.IsMeta(), + } +} +func documentModel(space core.SpaceRef, rev string, pinned bool, page *doc.Page, body []byte) *model.Document { + front, _ := doc.ParseFront(body) + return &model.Document{ + Space: space.String(), + ID: page.ID, + DocID: nilIfEmpty(page.DocID), + Path: page.Path, + Rev: rev, + Blob: page.Blob, + Pinned: pinned, + Title: page.Title, + Status: string(page.Status), + Section: page.Section, + Summary: page.Summary, + Type: front.Type, + Supersedes: front.Supersedes, + Tags: nonNil(page.Tags), + Owners: nonNil(front.Owners), + Markdown: string(body), + } +} +func proposalModel(p Proposal) (*model.Proposal, error) { + state, err := proposalState(p.State) + if err != nil { + return nil, err + } + m := &model.Proposal{ + ID: p.ID, + Space: p.Space.String(), + Title: p.Title, + Rationale: p.Rationale, + BaseRev: p.BaseRev, + Branch: p.Branch, + State: state, + MergedRev: nilIfEmpty(p.MergedRev), + Agent: p.Agent, + AgentSession: p.AgentSession, + Created: p.Created, + Resolved: p.Resolved, + } + // Approval is empty until a proposal merges, and the difference between + // human and policy approval is one a reader must be able to see: reporting + // either value for an unmerged proposal would launder unreviewed agent + // output as blessed, or claim a review that did not happen. + if p.Approval != "" { + approval, err := proposalApproval(p.Approval) + if err != nil { + return nil, err + } + m.Approval = &approval + } + return m, nil +} +func proposalState(s core.ProposalState) (model.ProposalState, error) { + out := model.ProposalState(strings.ToUpper(string(s))) + if !out.IsValid() { + return "", fmt.Errorf("proposal state %q is not one of %v", s, model.AllProposalState) + } + return out, nil +} +func proposalApproval(a core.Approval) (model.Approval, error) { + out := model.Approval(strings.ToUpper(string(a))) + if !out.IsValid() { + return "", fmt.Errorf("approval %q is not one of %v", a, model.AllApproval) + } + return out, nil +} +func spaceRef(owner, name string) (core.SpaceRef, error) { + ref := core.SpaceRef{Owner: strings.TrimSpace(owner), Name: strings.TrimSpace(name)} + if err := core.ValidateOwner(ref.Owner); err != nil { + return core.SpaceRef{}, fmt.Errorf("owner: %w", err) + } + if err := core.ValidateSpaceName(ref.Name); err != nil { + return core.SpaceRef{}, fmt.Errorf("name: %w", err) + } + return ref, nil +} +func projectRef(owner, name string) (core.ProjectRef, error) { + ref := core.ProjectRef{Owner: strings.TrimSpace(owner), Name: strings.TrimSpace(name)} + if err := core.ValidateOwner(ref.Owner); err != nil { + return core.ProjectRef{}, fmt.Errorf("owner: %w", err) + } + if ref.IsMeta() { + return ref, nil + } + if err := core.ValidateProjectName(ref.Name); err != nil { + return core.ProjectRef{}, fmt.Errorf("name: %w", err) + } + return ref, nil +} +func orNull(err error) error { + if errors.Is(err, service.ErrNotFound) { + return nil + } + return err +} +func deref(s *string) string { + if s == nil { + return "" + } + return *s +} +func nilIfEmpty(s string) *string { + if s == "" { + return nil + } + return &s +} +func nonNil(s []string) []string { + if s == nil { + return []string{} + } + return s +} diff --git a/graph/server.go b/graph/server.go new file mode 100644 index 0000000000000000000000000000000000000000..529dbc81b708b449a8ba0e45374074366a13ac68 --- /dev/null +++ b/graph/server.go @@ -0,0 +1,155 @@ +// Package graph is spec.sr.ht's GraphQL read schema, served at /query. +// +// # Read only, deliberately +// +// There are no mutations here. The design defers them until the proposal state +// machine has settled, and the reason is technical rather than scope +// discipline: the write plane's concurrency story is `If-Match: `, an +// HTTP idiom with well-defined 409 semantics that agents get right by default, +// and a type that has been federated into api.sr.ht is a consumed contract — +// expensive to churn. Read types (space, document, project, search) are stable +// from the start; the review types are not, and that is where the line is +// drawn. +// +// Serving GraphQL at all is justified without federation: Phase 5's webhooks +// are GraphQL-native so gqlgen arrives regardless, and this is the read surface +// anything on the instance that already speaks SourceHut GraphQL can consume. +// Federating into api.sr.ht is then one `api-origin=` line on the gateway that +// nothing here depends on — `hut` builds its endpoint from the per-service +// origin and talks to this /query directly either way. +// +// # Who may read +// +// The read plane is fail-closed and this is the same one-line ACL web/ applies: +// the instance owner and its agents may read, and nobody else may. A viewer +// with no read authority gets 401 before the query is parsed — including for +// introspection, which is why a gateway federating this schema has to present a +// token like any other client. +// +// # What the cmd layer must wire +// +// gql, err := graph.New(graph.Options{ +// Reader: svc, // *service.Service +// Searcher: index, // *search.Index +// Resolver: svc.Resolver(), +// }) +// if err != nil { +// return err +// } +// router.Handle("/query", gql.Handler()) +// +// [Server.Handler] installs authn's principal middleware itself, so it can be +// mounted on a router that has none. A caller whose router already resolves a +// principal uses [Server.Endpoint] instead. +package graph + +import ( + "fmt" + "net/http" + + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/transport" + + "sourcecraft.dev/bigbes/sr-ht-spec/authn" + "sourcecraft.dev/bigbes/sr-ht-spec/graph/api" +) + +// Options is everything a Server needs. New says which one is missing rather +// than failing later inside a resolver. +type Options struct { + // Reader is the orchestration layer. *service.Service satisfies it. + Reader Reader + + // Searcher is the one global keyword index. *search.Index satisfies it. + Searcher Searcher + + // Proposals is the proposal read side. It has no production implementation + // yet — see the Proposals interface — so it is the one optional field here, + // and while it is nil the `proposals` field of the schema fails with an + // error saying so rather than answering "none". + Proposals Proposals + + // Resolver turns the unified-login cookie or an agent bearer token into a + // principal. Handler installs its middleware; Endpoint does not. + Resolver *authn.Resolver +} + +// Server is the /query endpoint: the executable schema plus the read gate. It +// is built once at startup and is safe for concurrent use. +type Server struct { + exec http.Handler + resolver *authn.Resolver +} + +// New assembles the executable schema over the seams in opts. +func New(opts Options) (*Server, error) { + if opts.Reader == nil { + return nil, fmt.Errorf("graph: Reader is required") + } + if opts.Searcher == nil { + return nil, fmt.Errorf("graph: Searcher is required") + } + if opts.Resolver == nil { + return nil, fmt.Errorf("graph: authn Resolver is required") + } + root := &Resolver{ + reader: opts.Reader, + searcher: opts.Searcher, + proposals: opts.Proposals, + } + + // The transport set is core-go's, not gqlgen's NewDefaultServer: POST and + // introspection, and nothing else. NewDefaultServer would also install GET, + // multipart upload and a websocket transport — a second way in, a file + // upload path for a schema with no Upload scalar, and a subscription + // transport for a schema with no subscriptions. Every SourceHut service on + // this instance answers /query over POST, so a client that works against + // one works against this. + exec := handler.New(api.NewExecutableSchema(api.Config{Resolvers: root})) + exec.AddTransport(transport.POST{}) + exec.Use(extension.Introspection{}) + + return &Server{exec: exec, resolver: opts.Resolver}, nil +} + +// Handler is the /query handler with authn's principal middleware installed, so +// it can be mounted on a router that has none: +// +// router.Handle("/query", gql.Handler()) +// +// Installing that middleware twice is harmless — it is idempotent — so a router +// that already applies it may use this too. +func (s *Server) Handler() http.Handler { + return s.resolver.Middleware()(s.Endpoint()) +} + +// Endpoint is the /query handler without any middleware of its own. The router +// it is mounted on must already resolve a principal into the request context +// (authn.Resolver.Middleware), or every caller looks anonymous and is refused. +func (s *Server) Endpoint() http.Handler { + return gate(s.exec) +} + +// gate refuses a caller with no read authority before the query is parsed. +// +// One human, no visibility levels: the owner and its agents may read and nobody +// else may. A logged-in human who is not the instance owner has already been +// resolved to anonymous by authn, so this is the whole ACL — the same one web/ +// applies, spelled the same way, because two read surfaces with two policies is +// how a corpus leaks. +// +// The refusal is a 401 with a line of text and never a redirect to meta's +// login: every caller here is a machine, and handing a bot 200 and a page of +// login markup tells it nothing it can act on. +func gate(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + p := authn.PrincipalFromContext(r.Context()) + if !p.IsOwner() && !p.IsAgent() { + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + http.Error(w, "authentication required", http.StatusUnauthorized) + return + } + next.ServeHTTP(w, r) + }) +}