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

ComplexityRoot in the generated file is wrong when binding to ID #600

Closed
stobita opened this issue Mar 8, 2019 · 0 comments · Fixed by #622
Closed

ComplexityRoot in the generated file is wrong when binding to ID #600

stobita opened this issue Mar 8, 2019 · 0 comments · Fixed by #622
Labels
bug Something isn't working v0.8.2 Fixed in 0.8.2

Comments

@stobita
Copy link

stobita commented Mar 8, 2019

Expected Behaviour

I would like to prepare a Resolver for id in the query and return the ID value of model in another field.

Actual Behavior

From Version 0.8, setting it makes the ID field duplicated in ComplexityRoot in generated.go.

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
		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
	}
}

Minimal graphql.schema and models to reproduce

schema.graphql

type Todo {
  id: ID!
  todoId: Int!
  text: String!
  done: Boolean!
  user: User!
}

gqlgen.yml

models:
  Todo:
    model: gqlgen-sand/models.Todo
    fields:
      id:
        resolver: true
      todoId:
        fieldName: ID

models/todo.go

package models

type Todo struct {
	ID   int
	Text string
	Done bool
}
@mathewbyrne mathewbyrne added the bug Something isn't working label Mar 11, 2019
@vektah vektah added the v0.8.2 Fixed in 0.8.2 label Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.8.2 Fixed in 0.8.2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants