graphql-go / graphql-go/graphql
make union input type ? it just have output union type
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
`router.AddMutationField("test_union", types.IdType, graphql.FieldConfigArgument{
"input": &graphql.ArgumentConfig{
Type: graphql.NewList(searchInputType),
},
}, UpdateSetting)
type Book struct {
Title string `json:"title"`
Author string `json:"author"`
}
type Movie struct {
Title string `json:"title"`
Director string `json:"director"`
}
var bookType = graphql.NewObject(
graphql.ObjectConfig{
Name: "Book",
Fields: graphql.Fields{
"title": &graphql.Field{
Type: graphql.String,
},
"author": &graphql.Field{
Type: graphql.String,
},
"__typename": &graphql.Field{
Type: graphql.String,
},
},
},
)
var movieType = graphql.NewObject(
graphql.ObjectConfig{
Name: "Movie",
Fields: graphql.Fields{
"title": &graphql.Field{
Type: graphql.String,
},
"director": &graphql.Field{
Type: graphql.String,
}, "__typename": &graphql.Field{
Type: graphql.String,
},
},
},
)
var productUnion = graphql.NewUnion(graphql.UnionConfig{
Name: "Product",
Types: []*graphql.Object{
bookType, movieType,
},
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
switch p.Value.(type) {
case Book:
return bookType
case Movie:
return movieType
default:
return movieType
}
},
})
var searchInputType = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "SearchInput",
Fields: graphql.InputObjectConfigFieldMap{
"product": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(productUnion),
}, "__typename": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
},
})
`
when make this get Error: Introspection must provide input type for arguments.
Contributor guide
Assessment
This issue has not been assessed yet.