graphql-go / graphql-go/graphql
Help: Unable to Unmarshal from JSON to Struct
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
I have this JSON:
```json
{
"myField": {
"name": "",
"type": {
"name": "String",
"description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text."
},
"args": {
"myFieldName": {
"type": {
"ofType": {
"name": "String",
"description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text."
}
},
"defaultValue": null,
"description": ""
},
},
"deprecationReason": "",
"description": "Test"
}
}
```
When I want to unmarshal:
```go
var fields graphql.Fields
var fieldsEncoded []byte
// fieldsEncoded = ...
if err := json.Unmarshal(fieldsEncoded, &fields); err != nil {
fmt.Println(err)
}
```
I have this result:
```shell
json: cannot unmarshal object into Go struct field Field.type of type graphql.Output
```
Do you have an idea @chris-ramon or @dvic?
Contributor guide
Assessment
This issue has not been assessed yet.