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

interface conversion: interface {} is []interface {}, not map[string]interface {} #2958

Closed
voslartomas opened this issue Mar 7, 2024 · 3 comments

Comments

@voslartomas
Copy link
Contributor

voslartomas commented Mar 7, 2024

What happened?

After recent upgrade to newest gqlgen we encounter this error, it seems like it is newly generated for inputs like this

GearboxCreateLayoutInput:
    model: "map[string]interface{}"
interface conversion: interface{} is []interface{} not map[string]interface {}

It seems related to changes in 2839 or #2830

What did you expect?

Minimal graphql.schema and models to reproduce

versions

  • go run github.com/99designs/gqlgen version?
  • go version?
@Ned-el-ch
Copy link

Ned-el-ch commented Mar 7, 2024

to clarify,

input GearboxCreateLayoutInput {
  abc: String
  tiles: [GearboxLayoutTileInput]!
}

input GearboxLayoutTileInput {
  x: Int
  y: Int
}
GearboxCreateLayoutInput:
    model: "map[string]interface{}"
GearboxLayoutTileInput:
    model: "map[string]interface{}"

The tiles field ends up assumed as a map[string]interface{} instead of a []interface{}

case "tiles":
	ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tiles"))
	data, err := ec.unmarshalNGearboxLayoutTileInput2mapᚄ(ctx, v)
	if err != nil {
		return it, err
	}
	if err = ec.resolvers.GearboxLayoutInput().Tiles(ctx, &it, data); err != nil {
		return it, err
	}

imo there should be a type switch when dealing with an interface instead

@voslartomas
Copy link
Contributor Author

@endSly Hello, sorry to tag you in, but you might know if this issue is not tight to work you have done maybe?

@voslartomas
Copy link
Contributor Author

It was after all bug in our application.

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

2 participants