graphql-go / graphql-go/graphql

argument of type list<custom scalar type>

Open
#399 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.1k
Forks
845
PR merge metrics
No merged PRs in 30d

Description

Hi,

I created a custom scalar and wanted to use a list of it as arguments.

custom type:
```
var QLIDType = graphql.NewScalar(graphql.ScalarConfig{
Name: "id",
Serialize: func(value interface{}) interface{} {
return fmt.Sprintf("%v", value)
},
ParseValue: func(value interface{}) interface{} {
id, _ := models.IDFromString(fmt.Sprintf("%v", value))
return id
},
ParseLiteral: func(valueAST ast.Value) interface{} {
switch valueAST := valueAST.(type) {
case *ast.StringValue:
id, _ := models.IDFromString(valueAST.Value)
return id
default:
return nil
}
},
})
```

argument config:
```
Args: graphql.FieldConfigArgument{
"id": &graphql.ArgumentConfig{
Type: graphql.NewList(graphql.String),
},
},
```
But in the resolve function I just have a slice of interfaces. So it seems that the type given to NewList makes no difference. Is this an error or do I need to do it another way?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.