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

Strange functions on generated code #227

Closed
rodrigo-brito opened this issue Jul 25, 2018 · 8 comments
Closed

Strange functions on generated code #227

rodrigo-brito opened this issue Jul 25, 2018 · 8 comments

Comments

@rodrigo-brito
Copy link
Contributor

rodrigo-brito commented Jul 25, 2018

After upgrade to 0.3.0, gqlgen is generating strange functions on Resolver Interface:

type Resolvers interface {
    // ... My resolvers

    __Directive_args(ctx context.Context, obj *introspection.Directive) ([]introspection.InputValue, error)
 
    __Field_args(ctx context.Context, obj *introspection.Field) ([]introspection.InputValue, error)
 
    __Schema_types(ctx context.Context, obj *introspection.Schema) ([]introspection.Type, error)
 
    __Schema_directives(ctx context.Context, obj *introspection.Schema) ([]introspection.Directive, error)
 
    __Type_fields(ctx context.Context, obj *introspection.Type, includeDeprecated bool) ([]introspection.Field, error)
    __Type_interfaces(ctx context.Context, obj *introspection.Type) ([]introspection.Type, error)
    __Type_possibleTypes(ctx context.Context, obj *introspection.Type) ([]introspection.Type, error)
    __Type_enumValues(ctx context.Context, obj *introspection.Type, includeDeprecated bool) ([]introspection.EnumValue, error)
    __Type_inputFields(ctx context.Context, obj *introspection.Type) ([]introspection.InputValue, error)
}

ResolverRoot Interface:

type ResolverRoot interface {
    Mutation() MutationResolver
    Query() QueryResolver
    __Directive() __DirectiveResolver
    __Field() __FieldResolver
    __Schema() __SchemaResolver
    __Type() __TypeResolver
}

In the docs and examples these fields don't exists.

@mathewbyrne
Copy link
Contributor

@rodrigo-brito can you provide your schema.graphql and .gqlgen.yml? Those are all internal types that shouldn't have resolvers generated for them, so it's likely a bug somewhere. May already be resolved in the next branch with the new parser.

@rodrigo-brito
Copy link
Contributor Author

I tried to reproduce it in a simple example but don't works. Sometimes it happens but not everytime.

@mathewbyrne
Copy link
Contributor

I suspect you might have a versioning issue with your generated code. Make sure your gqlgen binary matches the runtime. If you come up with a way to reproduce, post back here.

@yamitzky
Copy link
Contributor

I encountered same issue. But I cannot reproduce it with starwars example 🤔

@yamitzky
Copy link
Contributor

my gqlgen binary version is 0.3.0 (381b346).

@yamitzky
Copy link
Contributor

yamitzky commented Jul 29, 2018

schema.graphql

schema {
  query: Query
}

type Query {
  test: Test
}

type Test {
  test: String!
}

.gqlgen.yml

schema: schema.graphql
exec:
  filename: gql/generated.go
  package: gql
model:
  filename: gql/models_gen.go
  package: gql
models:
  Test:
    model: path/to/my/package/gql.Test

gql/model.go

package gql

type Test struct {
	Test string
}

@rodrigo-brito
Copy link
Contributor Author

@mathewbyrne it is very strange. When we extract it, just don't happens.

@roderm
Copy link

roderm commented Oct 31, 2023

Just had the same Issue and found my problem. In the autobind in the gqlgen.yml I included a module that contained a Field-struct. So instead of introspection.Field, mypackage.Field was used.
My fix was to just include github.com/99designs/gqlgen/graphql/introspection as first autobind.

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

4 participants