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

Bug with underscore and same name in keys from json response #675

Open
manuelabarca opened this issue Aug 2, 2023 · 0 comments
Open

Bug with underscore and same name in keys from json response #675

manuelabarca opened this issue Aug 2, 2023 · 0 comments

Comments

@manuelabarca
Copy link

Good afternoon, I am having a problem with a json that comes as a response to an external endpoint. This json brings the following key values.

{
"_type": "product_result",
"type": {
  "_type": "product_type",
  "master": true
 }
}

When I assemble the graphql object, I assemble it as follows.

"_type": &graphql.Field{
				Type: graphql.String,
			},
"type": &graphql.Field{ Type.
				Type: GQLProductType,
			},


var GQLProductType = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Type",
		Fields: graphql.Fields{
			"_type": &graphql.Field{
				Type: graphql.String,
			},
			"master": &graphql.Field{
				Type: graphql.Boolean,
			},
		},
	})

but when I launch the query to see if everything is working, the first field arrives ok but the second one that brings an object, the values of the keys of the object are null. I made the test eliminating or omitting the first "_type" and then the results are not null in the object of the second field. It is as if it replaced it or got confused when replacing things. Has anyone had something similar happen? or do you know if there is a problem with underscored key names? As if _type is equal to type and that's why this "bug" happens?

Greetings.

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