I previously registered my type Address as a Type and it worked well to output data of this type.
Now I'd also like to be able to pass in an Address as an argument of a query and I simply can't wrap my head around a way to do it.
Without any other code change I get:
Fatal error: 'try!' expression unexpectedly raised an error: ⚠️ GraphQLError: Cannot use type "Optional<Address>" for field "myField". Mapped GraphQL type is not an input type.
- id: GraphQLError.GraphQLError
: file ../Graphiti/Schema/Query.swift, line 30
But if I then register it as a Input as well, I get a duplicated type error:
Fatal error: 'try!' expression unexpectedly raised an error: ⚠️ GraphQLError: Duplicate type registration: Address
- id: GraphQLError.GraphQLError
: file ../Graphiti/Schema/Input.swift, line 75
and finally I tried registering the type as only an Input but it still doesn't work:
Fatal error: 'try!' expression unexpectedly raised an error: ⚠️ GraphQLError: Resolved type "Address" is not a valid output type.
- id: GraphQLError.GraphQLError
: file ../Graphiti/Schema/Schema.swift, line 113
Is there a way to do that without duplicating the code?
I previously registered my type
Address
as aType
and it worked well to output data of this type. Now I'd also like to be able to pass in anAddress
as an argument of a query and I simply can't wrap my head around a way to do it. Without any other code change I get:But if I then register it as a
Input
as well, I get a duplicated type error:and finally I tried registering the type as only an
Input
but it still doesn't work:Is there a way to do that without duplicating the code?