diff --git a/example/chat/server/server.go b/example/chat/server/server.go index 6fa6954b3dd..b3f313acd3e 100644 --- a/example/chat/server/server.go +++ b/example/chat/server/server.go @@ -8,7 +8,6 @@ import ( "github.com/99designs/gqlgen/example/chat" "github.com/99designs/gqlgen/handler" - gqlopentracing "github.com/99designs/gqlgen/opentracing" "github.com/gorilla/websocket" "github.com/opentracing/opentracing-go" "sourcegraph.com/sourcegraph/appdash" @@ -21,8 +20,6 @@ func main() { http.Handle("/", handler.Playground("Todo", "/query")) http.Handle("/query", handler.GraphQL(chat.NewExecutableSchema(chat.New()), - handler.ResolverMiddleware(gqlopentracing.ResolverMiddleware()), - handler.RequestMiddleware(gqlopentracing.RequestMiddleware()), handler.WebsocketUpgrader(websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true diff --git a/gqlapollotracing/extension.go b/gqlapollotracing/extension.go deleted file mode 100644 index 653fd41fc0c..00000000000 --- a/gqlapollotracing/extension.go +++ /dev/null @@ -1,62 +0,0 @@ -package gqlapollotracing - -import ( - "sync" - "time" -) - -type tracingData struct { - mu sync.Mutex - - StartTime time.Time `json:"startTime"` - EndTime time.Time `json:"endTime"` - Duration time.Duration `json:"duration"` - Parsing *startOffset `json:"parsing"` - Validation *startOffset `json:"validation"` - Execution *execution `json:"execution"` -} - -func (td *tracingData) prepare() { - td.Duration = td.EndTime.Sub(td.StartTime) - if td.Parsing != nil { - td.Parsing.prepare(td) - } - if td.Validation != nil { - td.Validation.prepare(td) - } - if td.Execution != nil { - td.Execution.prepare(td) - } -} - -type startOffset struct { - StartTime time.Time `json:"-"` - EndTime time.Time `json:"-"` - - StartOffset time.Duration `json:"startOffset"` - Duration time.Duration `json:"duration"` -} - -func (so *startOffset) prepare(td *tracingData) { - so.StartOffset = so.StartTime.Sub(td.StartTime) - so.Duration = so.EndTime.Sub(so.StartTime) -} - -type execution struct { - Resolvers []*executionSpan `json:"resolvers"` -} - -func (e *execution) prepare(td *tracingData) { - for _, es := range e.Resolvers { - es.prepare(td) - } -} - -type executionSpan struct { - startOffset - - Path []interface{} `json:"path"` - ParentType string `json:"parentType"` - FieldName string `json:"fieldName"` - ReturnType string `json:"returnType"` -} diff --git a/gqlapollotracing/internal/gqlapollotracingtest/generated.go b/gqlapollotracing/internal/gqlapollotracingtest/generated.go deleted file mode 100644 index eed876840ce..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/generated.go +++ /dev/null @@ -1,2240 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package gqlapollotracingtest - -import ( - bytes "bytes" - context "context" - strconv "strconv" - sync "sync" - - graphql "github.com/99designs/gqlgen/graphql" - introspection "github.com/99designs/gqlgen/graphql/introspection" - gqlparser "github.com/vektah/gqlparser" - ast "github.com/vektah/gqlparser/ast" -) - -// 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 { - Mutation() MutationResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Mutation struct { - CreateTodo func(childComplexity int, input NewTodo) int - } - - Query struct { - Todos func(childComplexity int) int - } - - Todo struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - User func(childComplexity int) int - } - - User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - } -} - -type MutationResolver interface { - CreateTodo(ctx context.Context, input NewTodo) (Todo, error) -} -type QueryResolver interface { - Todos(ctx context.Context) ([]Todo, error) -} - -func field_Mutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 NewTodo - if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalNewTodo(tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil - -} - -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -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) { - switch typeName + "." + field { - - case "Mutation.createTodo": - if e.complexity.Mutation.CreateTodo == nil { - break - } - - args, err := field_Mutation_createTodo_args(rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true - - case "Query.todos": - if e.complexity.Query.Todos == nil { - break - } - - return e.complexity.Query.Todos(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break - } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.done": - if e.complexity.Todo.Done == nil { - break - } - - return e.complexity.Todo.Done(childComplexity), true - - case "Todo.user": - if e.complexity.Todo.User == nil { - break - } - - return e.complexity.Todo.User(childComplexity), true - - case "User.id": - if e.complexity.User.Id == nil { - break - } - - return e.complexity.User.Id(childComplexity), true - - case "User.name": - if e.complexity.User.Name == nil { - break - } - - return e.complexity.User.Name(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var mutationImplementors = []string{"Mutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, mutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Mutation", - }) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "createTodo": - out.Values[i] = ec._Mutation_createTodo(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Mutation_createTodo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx := &graphql.ResolverContext{ - Object: "Mutation", - Args: args, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) -} - -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) - - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "todos": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_todos(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - wg.Done() - }(i, field) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - wg.Wait() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Query", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx := &graphql.ResolverContext{ - Object: "Query", - Args: args, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Query", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -var todoImplementors = []string{"Todo"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, todoImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Todo") - case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "done": - out.Values[i] = ec._Todo_done(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "user": - out.Values[i] = ec._Todo_user(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Todo", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Todo", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Text, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Todo", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Done, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "Todo", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._User(ctx, field.Selections, &res) -} - -var userImplementors = []string{"User"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, userImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "User", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "User", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - 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 { - invalid = true - } - 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 { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - 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 { - invalid = true - } - 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 { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - 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 { - invalid = true - } - 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 { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Field", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - 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 { - invalid = true - } - 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 { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - 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 { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - 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 { - invalid = true - } - 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) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: args, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: args, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer ec.Tracer.EndFieldExecution(ctx) - rctx := &graphql.ResolverContext{ - Object: "__Type", - Args: nil, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -func UnmarshalNewTodo(v interface{}) (NewTodo, error) { - var it NewTodo - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "text": - var err error - it.Text, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - case "userId": - var err error - it.UserID, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() *introspection.Schema { - return introspection.WrapSchema(parsedSchema) -} - -func (ec *executionContext) introspectType(name string) *introspection.Type { - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]) -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `# GraphQL schema example -# -# https://gqlgen.com/getting-started/ - -type Todo { - id: ID! - text: String! - done: Boolean! - user: User! -} - -type User { - id: ID! - name: String! -} - -type Query { - todos: [Todo!]! -} - -input NewTodo { - text: String! - userId: String! -} - -type Mutation { - createTodo(input: NewTodo!): Todo! -}`}, -) diff --git a/gqlapollotracing/internal/gqlapollotracingtest/gqlgen.yml b/gqlapollotracing/internal/gqlapollotracingtest/gqlgen.yml deleted file mode 100644 index d44a4335716..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/gqlgen.yml +++ /dev/null @@ -1,14 +0,0 @@ -# .gqlgen.yml example -# -# Refer to https://gqlgen.com/config/ -# for detailed .gqlgen.yml documentation. - -schema: -- schema.graphql -exec: - filename: generated.go -model: - filename: models_gen.go -resolver: - filename: resolver.go - type: Resolver diff --git a/gqlapollotracing/internal/gqlapollotracingtest/models_gen.go b/gqlapollotracing/internal/gqlapollotracingtest/models_gen.go deleted file mode 100644 index eb4857ae07e..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/models_gen.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package gqlapollotracingtest - -type NewTodo struct { - Text string `json:"text"` - UserID string `json:"userId"` -} - -type Todo struct { - ID string `json:"id"` - Text string `json:"text"` - Done bool `json:"done"` - User User `json:"user"` -} - -type User struct { - ID string `json:"id"` - Name string `json:"name"` -} diff --git a/gqlapollotracing/internal/gqlapollotracingtest/resolver.go b/gqlapollotracing/internal/gqlapollotracingtest/resolver.go deleted file mode 100644 index b454566a27a..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/resolver.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:generate gorunpkg github.com/99designs/gqlgen - -package gqlapollotracingtest - -import ( - "context" - "fmt" -) - -func NewResolver() *Resolver { - return &Resolver{ - todos: []Todo{ - { - ID: "Todo:1", - Text: "Play with cat", - Done: true, - User: User{ - ID: "User:foobar", - Name: "foobar", - }, - }, - }, - } -} - -type Resolver struct { - todos []Todo -} - -func (r *Resolver) Mutation() MutationResolver { - return &mutationResolver{r} -} -func (r *Resolver) Query() QueryResolver { - return &queryResolver{r} -} - -type mutationResolver struct{ *Resolver } - -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { - todo := Todo{ - ID: fmt.Sprintf("Todo:%d", len(r.todos)+1), - Text: input.Text, - User: User{ - ID: input.UserID, - Name: input.UserID, - }, - } - r.todos = append(r.todos, todo) - return todo, nil -} - -type queryResolver struct{ *Resolver } - -func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { - return r.todos, nil -} diff --git a/gqlapollotracing/internal/gqlapollotracingtest/schema.graphql b/gqlapollotracing/internal/gqlapollotracingtest/schema.graphql deleted file mode 100644 index f6e1bac5662..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/schema.graphql +++ /dev/null @@ -1,28 +0,0 @@ -# GraphQL schema example -# -# https://gqlgen.com/getting-started/ - -type Todo { - id: ID! - text: String! - done: Boolean! - user: User! -} - -type User { - id: ID! - name: String! -} - -type Query { - todos: [Todo!]! -} - -input NewTodo { - text: String! - userId: String! -} - -type Mutation { - createTodo(input: NewTodo!): Todo! -} \ No newline at end of file diff --git a/gqlapollotracing/internal/gqlapollotracingtest/server/server.go b/gqlapollotracing/internal/gqlapollotracingtest/server/server.go deleted file mode 100644 index 9ff3a8fa131..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/server/server.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - log "log" - http "net/http" - os "os" - - gqlapollotracingtest "github.com/99designs/gqlgen/gqlapollotracing/internal/gqlapollotracingtest" - handler "github.com/99designs/gqlgen/handler" -) - -const defaultPort = "8080" - -func main() { - port := os.Getenv("PORT") - if port == "" { - port = defaultPort - } - - http.Handle("/", handler.Playground("GraphQL playground", "/query")) - http.Handle("/query", handler.GraphQL(gqlapollotracingtest.NewExecutableSchema(gqlapollotracingtest.Config{Resolvers: &gqlapollotracingtest.Resolver{}}))) - - log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) - log.Fatal(http.ListenAndServe(":"+port, nil)) -} diff --git a/gqlapollotracing/internal/gqlapollotracingtest/tracer_test.go b/gqlapollotracing/internal/gqlapollotracingtest/tracer_test.go deleted file mode 100644 index 82a54d89e6f..00000000000 --- a/gqlapollotracing/internal/gqlapollotracingtest/tracer_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package gqlapollotracingtest - -import ( - "net/http" - "net/http/httptest" - "strings" - "sync" - "testing" - "time" - - "github.com/99designs/gqlgen/gqlapollotracing" - "github.com/99designs/gqlgen/handler" - "github.com/stretchr/testify/assert" -) - -func TestNewTracer(t *testing.T) { - h := handler.GraphQL( - NewExecutableSchema( - Config{ - Resolvers: NewResolver(), - }, - ), - handler.RequestMiddleware(gqlapollotracing.RequestMiddleware()), - handler.Tracer(gqlapollotracing.NewTracer()), - ) - - t.Run("success", func(t *testing.T) { - var mu sync.Mutex - now := time.Date(2018, 10, 30, 9, 0, 0, 0, time.UTC) - gqlapollotracing.SetTimeNowFunc(func() time.Time { - mu.Lock() - defer mu.Unlock() - now = now.Add(100 * time.Millisecond) - return now - }) - defer gqlapollotracing.SetTimeNowFunc(time.Now) - - resp := doRequest(h, "POST", "/query", `{"query":"{ todos { id text } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"todos":[{"id":"Todo:1","text":"Play with cat"}]},"extensions":{"tracing":{"startTime":"2018-10-30T09:00:00.1Z","endTime":"2018-10-30T09:00:01.1Z","duration":1000000000,"parsing":{"startOffset":0,"duration":100000000},"validation":{"startOffset":200000000,"duration":100000000},"execution":{"resolvers":[{"startOffset":400000000,"duration":500000000,"path":["todos"],"parentType":"Query","fieldName":"todos","returnType":"[Todo!]!"},{"startOffset":500000000,"duration":100000000,"path":["todos",0,"id"],"parentType":"Todo","fieldName":"id","returnType":"ID!"},{"startOffset":700000000,"duration":100000000,"path":["todos",0,"text"],"parentType":"Todo","fieldName":"text","returnType":"String!"}]}}}}`, resp.Body.String()) - }) -} - -func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { - r := httptest.NewRequest(method, target, strings.NewReader(body)) - w := httptest.NewRecorder() - - handler.ServeHTTP(w, r) - return w -} diff --git a/gqlapollotracing/middleware.go b/gqlapollotracing/middleware.go deleted file mode 100644 index 2f2ce31eaad..00000000000 --- a/gqlapollotracing/middleware.go +++ /dev/null @@ -1,23 +0,0 @@ -package gqlapollotracing - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" -) - -func RequestMiddleware() graphql.RequestMiddleware { - return func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - res := next(ctx) - - reqCtx := graphql.GetRequestContext(ctx) - td := getTracingData(ctx) - - err := reqCtx.RegisterExtension("tracing", td) - if err != nil { - reqCtx.Error(ctx, err) - } - - return res - } -} diff --git a/gqlapollotracing/test_helper.go b/gqlapollotracing/test_helper.go deleted file mode 100644 index a67bd368ee5..00000000000 --- a/gqlapollotracing/test_helper.go +++ /dev/null @@ -1,7 +0,0 @@ -package gqlapollotracing - -import "time" - -func SetTimeNowFunc(f func() time.Time) { - timeNowFunc = f -} diff --git a/gqlapollotracing/tracer.go b/gqlapollotracing/tracer.go deleted file mode 100644 index fc204f87ac0..00000000000 --- a/gqlapollotracing/tracer.go +++ /dev/null @@ -1,107 +0,0 @@ -package gqlapollotracing - -import ( - "context" - "time" - - "github.com/99designs/gqlgen/graphql" -) - -var _ graphql.Tracer = (*tracerImpl)(nil) - -func NewTracer() graphql.Tracer { - return &tracerImpl{} -} - -var timeNowFunc = time.Now - -var ctxTracingKey = &struct{ tmp string }{} -var ctxExecSpanKey = &struct{ tmp string }{} - -type tracerImpl struct { -} - -func getTracingData(ctx context.Context) *tracingData { - return ctx.Value(ctxTracingKey).(*tracingData) -} - -func getExecutionSpan(ctx context.Context) *executionSpan { - return ctx.Value(ctxExecSpanKey).(*executionSpan) -} - -func (t *tracerImpl) StartOperationParsing(ctx context.Context) context.Context { - now := timeNowFunc() - td := &tracingData{ - StartTime: now, - Parsing: &startOffset{ - StartTime: now, - }, - } - ctx = context.WithValue(ctx, ctxTracingKey, td) - return ctx -} - -func (t *tracerImpl) EndOperationParsing(ctx context.Context) { - td := getTracingData(ctx) - td.Parsing.EndTime = timeNowFunc() -} - -func (t *tracerImpl) StartOperationValidation(ctx context.Context) context.Context { - td := getTracingData(ctx) - td.Validation = &startOffset{} - td.Validation.StartTime = timeNowFunc() - return ctx -} - -func (t *tracerImpl) EndOperationValidation(ctx context.Context) { - td := getTracingData(ctx) - td.Validation.EndTime = timeNowFunc() -} - -func (t *tracerImpl) StartOperationExecution(ctx context.Context) context.Context { - return ctx -} - -func (t *tracerImpl) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - - td := getTracingData(ctx) - es := &executionSpan{ - startOffset: startOffset{ - StartTime: timeNowFunc(), - }, - ParentType: field.ObjectDefinition.Name, - FieldName: field.Name, - ReturnType: field.Definition.Type.String(), - } - ctx = context.WithValue(ctx, ctxExecSpanKey, es) - td.mu.Lock() - defer td.mu.Unlock() - if td.Execution == nil { - td.Execution = &execution{} - } - td.Execution.Resolvers = append(td.Execution.Resolvers, es) - - return ctx -} - -func (t *tracerImpl) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - es := getExecutionSpan(ctx) - es.Path = rc.Path() - - return ctx -} - -func (t *tracerImpl) StartFieldChildExecution(ctx context.Context) context.Context { - return ctx -} - -func (t *tracerImpl) EndFieldExecution(ctx context.Context) { - es := getExecutionSpan(ctx) - es.EndTime = timeNowFunc() -} - -func (t *tracerImpl) EndOperationExecution(ctx context.Context) { - td := getTracingData(ctx) - td.EndTime = timeNowFunc() - td.prepare() -} diff --git a/gqlopencensus/datadog.go b/gqlopencensus/datadog.go deleted file mode 100644 index f9f9c973b93..00000000000 --- a/gqlopencensus/datadog.go +++ /dev/null @@ -1,34 +0,0 @@ -package gqlopencensus - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" - "go.opencensus.io/trace" -) - -// WithDataDog provides DataDog specific span attrs. -// see github.com/DataDog/opencensus-go-exporter-datadog -func WithDataDog() Option { - return func(cfg *config) { - cfg.tracer = &datadogTracerImpl{cfg.tracer} - } -} - -type datadogTracerImpl struct { - graphql.Tracer -} - -func (dt *datadogTracerImpl) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - ctx = dt.Tracer.StartFieldResolverExecution(ctx, rc) - span := trace.FromContext(ctx) - if !span.IsRecordingEvents() { - return ctx - } - span.AddAttributes( - // key from gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext#ResourceName - trace.StringAttribute("resource.name", operationName(ctx)), - ) - - return ctx -} diff --git a/gqlopencensus/option.go b/gqlopencensus/option.go deleted file mode 100644 index 00b3037e687..00000000000 --- a/gqlopencensus/option.go +++ /dev/null @@ -1,10 +0,0 @@ -package gqlopencensus - -import "github.com/99designs/gqlgen/graphql" - -type config struct { - tracer graphql.Tracer -} - -// Option is anything that can configure Tracer. -type Option func(cfg *config) diff --git a/gqlopencensus/tracer.go b/gqlopencensus/tracer.go deleted file mode 100644 index 74e0cc52789..00000000000 --- a/gqlopencensus/tracer.go +++ /dev/null @@ -1,125 +0,0 @@ -package gqlopencensus - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/graphql" - "go.opencensus.io/trace" -) - -var _ graphql.Tracer = (tracerImpl)(0) - -// New returns Tracer for OpenCensus. -// see https://go.opencensus.io/trace -func New(opts ...Option) graphql.Tracer { - var tracer tracerImpl - cfg := &config{tracer} - - for _, opt := range opts { - opt(cfg) - } - - return cfg.tracer -} - -type tracerImpl int - -func (tracerImpl) StartOperationParsing(ctx context.Context) context.Context { - return ctx -} - -func (tracerImpl) EndOperationParsing(ctx context.Context) { -} - -func (tracerImpl) StartOperationValidation(ctx context.Context) context.Context { - return ctx -} - -func (tracerImpl) EndOperationValidation(ctx context.Context) { -} - -func (tracerImpl) StartOperationExecution(ctx context.Context) context.Context { - ctx, span := trace.StartSpan(ctx, operationName(ctx)) - if !span.IsRecordingEvents() { - return ctx - } - requestContext := graphql.GetRequestContext(ctx) - span.AddAttributes( - trace.StringAttribute("request.query", requestContext.RawQuery), - ) - if requestContext.ComplexityLimit > 0 { - span.AddAttributes( - trace.Int64Attribute("request.complexityLimit", int64(requestContext.ComplexityLimit)), - trace.Int64Attribute("request.operationComplexity", int64(requestContext.OperationComplexity)), - ) - } - - for key, val := range requestContext.Variables { - span.AddAttributes( - trace.StringAttribute(fmt.Sprintf("request.variables.%s", key), fmt.Sprintf("%+v", val)), - ) - } - - return ctx -} - -func (tracerImpl) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - ctx, span := trace.StartSpan(ctx, field.ObjectDefinition.Name+"/"+field.Name) - if !span.IsRecordingEvents() { - return ctx - } - span.AddAttributes( - trace.StringAttribute("resolver.object", field.ObjectDefinition.Name), - trace.StringAttribute("resolver.field", field.Name), - trace.StringAttribute("resolver.alias", field.Alias), - ) - for _, arg := range field.Arguments { - if arg.Value != nil { - span.AddAttributes( - trace.StringAttribute(fmt.Sprintf("resolver.args.%s", arg.Name), arg.Value.String()), - ) - } - } - - return ctx -} - -func (tracerImpl) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - span := trace.FromContext(ctx) - if !span.IsRecordingEvents() { - return ctx - } - span.AddAttributes( - trace.StringAttribute("resolver.path", fmt.Sprintf("%+v", rc.Path())), - ) - - return ctx -} - -func (tracerImpl) StartFieldChildExecution(ctx context.Context) context.Context { - return ctx -} - -func (tracerImpl) EndFieldExecution(ctx context.Context) { - span := trace.FromContext(ctx) - defer span.End() -} - -func (tracerImpl) EndOperationExecution(ctx context.Context) { - span := trace.FromContext(ctx) - defer span.End() -} - -func operationName(ctx context.Context) string { - requestContext := graphql.GetRequestContext(ctx) - requestName := "nameless-operation" - if requestContext.Doc != nil && len(requestContext.Doc.Operations) != 0 { - op := requestContext.Doc.Operations[0] - if op.Name != "" { - requestName = op.Name - } - } - - return requestName -} diff --git a/gqlopencensus/tracer_test.go b/gqlopencensus/tracer_test.go deleted file mode 100644 index bd20137faf1..00000000000 --- a/gqlopencensus/tracer_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package gqlopencensus_test - -import ( - "context" - "sync" - "testing" - - "github.com/99designs/gqlgen/gqlopencensus" - "github.com/99designs/gqlgen/graphql" - "github.com/stretchr/testify/assert" - "github.com/vektah/gqlparser/ast" - "go.opencensus.io/trace" -) - -var _ trace.Exporter = (*testExporter)(nil) - -type testExporter struct { - sync.Mutex - - Spans []*trace.SpanData -} - -func (te *testExporter) ExportSpan(s *trace.SpanData) { - te.Lock() - defer te.Unlock() - - te.Spans = append(te.Spans, s) -} - -func (te *testExporter) Reset() { - te.Lock() - defer te.Unlock() - - te.Spans = nil -} - -func TestTracer(t *testing.T) { - var mu sync.Mutex - - exporter := &testExporter{} - - trace.RegisterExporter(exporter) - defer trace.UnregisterExporter(exporter) - - specs := []struct { - SpecName string - Tracer graphql.Tracer - Sampler trace.Sampler - ExpectedAttrs []map[string]interface{} - }{ - { - SpecName: "with sampling", - Tracer: gqlopencensus.New(), - Sampler: trace.AlwaysSample(), - ExpectedAttrs: []map[string]interface{}{ - { - "resolver.object": "OD", - "resolver.field": "F", - "resolver.alias": "F", - "resolver.path": "[]", - }, - { - "request.query": "query { foobar }", - "request.variables.fizz": "buzz", - "request.complexityLimit": int64(1000), - "request.operationComplexity": int64(100), - }, - }, - }, - { - SpecName: "without sampling", - Tracer: gqlopencensus.New(), - Sampler: trace.NeverSample(), - ExpectedAttrs: nil, - }, - { - SpecName: "with sampling & DataDog", - Tracer: gqlopencensus.New(gqlopencensus.WithDataDog()), - Sampler: trace.AlwaysSample(), - ExpectedAttrs: []map[string]interface{}{ - { - "resolver.object": "OD", - "resolver.field": "F", - "resolver.alias": "F", - "resolver.path": "[]", - "resource.name": "nameless-operation", - }, - { - "request.query": "query { foobar }", - "request.variables.fizz": "buzz", - "request.complexityLimit": int64(1000), - "request.operationComplexity": int64(100), - }, - }, - }, - { - SpecName: "without sampling & DataDog", - Tracer: gqlopencensus.New(gqlopencensus.WithDataDog()), - Sampler: trace.NeverSample(), - ExpectedAttrs: nil, - }, - } - - for _, spec := range specs { - t.Run(spec.SpecName, func(t *testing.T) { - mu.Lock() - defer mu.Unlock() - exporter.Reset() - - tracer := spec.Tracer - ctx := context.Background() - ctx = graphql.WithRequestContext(ctx, &graphql.RequestContext{ - RawQuery: "query { foobar }", - Variables: map[string]interface{}{ - "fizz": "buzz", - }, - ComplexityLimit: 1000, - OperationComplexity: 100, - }) - ctx, _ = trace.StartSpan(ctx, "test", trace.WithSampler(spec.Sampler)) - ctx = tracer.StartOperationExecution(ctx) - { - ctx2 := tracer.StartFieldExecution(ctx, graphql.CollectedField{ - Field: &ast.Field{ - Name: "F", - Alias: "F", - ObjectDefinition: &ast.Definition{ - Name: "OD", - }, - }, - }) - ctx2 = tracer.StartFieldResolverExecution(ctx2, &graphql.ResolverContext{}) - ctx2 = tracer.StartFieldChildExecution(ctx2) - tracer.EndFieldExecution(ctx2) - } - tracer.EndOperationExecution(ctx) - - if len(spec.ExpectedAttrs) == 0 && len(exporter.Spans) != 0 { - t.Errorf("unexpected spans: %+v", exporter.Spans) - } else if len(spec.ExpectedAttrs) != len(exporter.Spans) { - assert.Equal(t, len(spec.ExpectedAttrs), len(exporter.Spans)) - } else { - for idx, expectedAttrs := range spec.ExpectedAttrs { - span := exporter.Spans[idx] - assert.Equal(t, expectedAttrs, span.Attributes) - } - } - }) - } -} diff --git a/opentracing/opentracing.go b/opentracing/opentracing.go deleted file mode 100644 index a9b900e30a9..00000000000 --- a/opentracing/opentracing.go +++ /dev/null @@ -1,51 +0,0 @@ -package opentracing - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/graphql" - "github.com/opentracing/opentracing-go" - "github.com/opentracing/opentracing-go/ext" - "github.com/opentracing/opentracing-go/log" -) - -func ResolverMiddleware() graphql.FieldMiddleware { - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - rctx := graphql.GetResolverContext(ctx) - span, ctx := opentracing.StartSpanFromContext(ctx, rctx.Object+"_"+rctx.Field.Name, - opentracing.Tag{Key: "resolver.object", Value: rctx.Object}, - opentracing.Tag{Key: "resolver.field", Value: rctx.Field.Name}, - ) - defer span.Finish() - ext.SpanKind.Set(span, "server") - ext.Component.Set(span, "gqlgen") - - res, err := next(ctx) - - if err != nil { - ext.Error.Set(span, true) - span.LogFields( - log.String("event", "error"), - log.String("message", err.Error()), - log.String("error.kind", fmt.Sprintf("%T", err)), - ) - } - - return res, err - } -} - -func RequestMiddleware() graphql.RequestMiddleware { - return func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - requestContext := graphql.GetRequestContext(ctx) - span, ctx := opentracing.StartSpanFromContext(ctx, requestContext.RawQuery) - defer span.Finish() - ext.SpanKind.Set(span, "server") - ext.Component.Set(span, "gqlgen") - - res := next(ctx) - - return res - } -}