Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unused parameter: ctx warnings in generated.go #3004

Open
amorey opened this issue Apr 12, 2024 · 0 comments
Open

unused parameter: ctx warnings in generated.go #3004

amorey opened this issue Apr 12, 2024 · 0 comments

Comments

@amorey
Copy link

amorey commented Apr 12, 2024

What happened?

The code in generated.go contains unused parameters that triggers warnings in vscode (e.g. "unused parameter: ctx"). For example, generated.go produces code like this:

func (ec *executionContext) fieldContext_Query_todos(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_Todo_id(ctx, field)
			case "text":
				return ec.fieldContext_Todo_text(ctx, field)
			case "done":
				return ec.fieldContext_Todo_done(ctx, field)
			case "user":
				return ec.fieldContext_Todo_user(ctx, field)
			}
			return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name)
		},
	}
	return fc, nil
}

What did you expect?

Generated code not to trigger warnings.

Minimal graphql.schema and models to reproduce

Running the gqlgen-todos quickstart example produces code that triggers the unused parameter warnings.

versions

  • go run github.com/99designs/gqlgen version? 0.17.45
  • go version? 1.21.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant