Replies: 1 comment
-
I'm also curious about this! I'm designing an API that looks like this: type Foo {
# fields
}
input FooInput {
# exact same fields as foo
}
type Query {
getFoos: [Foo]
}
type Mutation {
newFoo(input: FooInput): Foo
}
Using autobind, I can have However, since I can't use It would be nice if I didn't need to do that. Also, I agree with @BatmanAoD that it would also be nice for the schema to be simpler. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is related to #1223, but that doesn't quite capture my question, and I couldn't find anything more related. I didn't exactly follow the template because this is a feature request rather than a bug report.
GraphQL requires non-scalar parameter types to be defined with
input
, rather thantype
. This means that if you have an input value and an output value that structurally match, you nevertheless must write separate types for them.But when mapping these types to Go structs, there's no reason to have them duplicated other than to ensure that the names match. So, for example:
If it's important to have Go structs with
...Input
in the names, then the existing model-generation works fine. But in some cases it may be more useful to de-duplicate these structs, producing:The
Foo
struct can now be used to serialize or deserialize both theFoo
andFooInput
GraphQL types.Ideally, I would like a way to globally detect instances where
type <name>
andinput *<name>*
exist in the schema, and theinput
type has the same structure (where inner fields with non-scalar types have the same property, recursively). But as an alternative, generation of theinput
types could be explicitly suppressed on a per-type basis.Is this possible, or a feature you would consider adding?
Beta Was this translation helpful? Give feedback.
All reactions