graphql-go
graphql-go copied to clipboard
Additional fields on interface implementer do not set default values
Expected behavior
Given the schema
interface Namer {
name: String!
}
type User implements Namer {
id: ID!
name(type: NameType = FULL): String!
email: String!
}
enum NameType {
FULL
FIRST
LAST
}
type Query {
namedThings: [Namer]
}
and the query
{
namedThings {
name
}
}
I would expect the name
field resolver to receive the default argument value for the argument type
when the Namer
being resolved is a User
.
func (r *UserResolver) Name(args *struct{Type string}) string {
switch args.Type {
case "":
panic("argument 'type' should have a value!")
default:
// the value was set, continue
}
return ""
}
Actual behavior
The value of the type
argument is un-set. If the field resolver was written as above, the panic would be triggered.