I have a problem related to a Mutation/Subscription on AWS Appsync, using a local data source (i.e., a Data Source of type NONE). I need to feed the mutation with data defined as a type
in the schema and it contains several fields (some other type
inside it as well). Let's call it Profile
type Profile {
id: ID
name: String
address: Address
email: String
}
type Address {
street: String
number: String
city: String
zipcode: Int
}
Profile
is already there in the schema as a type
because it is used in a Subscription.
In order to do so, following the AppSync rules, I should need to create an input
and recreate all the fields from the original type
, let's call it InputProfile
.
input InputProfile {
id: ID
name: String
address: InputAddress
email: String
}
type InputAddress {
street: String
number: String
city: String
zipcode: Int
}
Now I do not want to merely duplicate all the fields and subfields from the original
data Profile
but I would like to just use it straight in some way. This comes
from the need to not have duplicates (Profile
and InputProfile
) but to just
have all the fields in one type
. In that way it would easier to maintain and
if any change arises, the modification could be done in the same point in the code
rather than in two points, thus leading to possibile misalignments or mistakes.
In addition to this, please note that in order to achieve this result, it is
also needed to duplicate any complex subfield (i.e. another type
) in Profile
with a corresponding input
in InputProfile
. As you could imagine, it leads
to a useless amount of duplicates that should be avoided.
I also tried to feed the mutation directly with Profile
but AppSync gives an
error as it expects it to be an input
.
Do you have any advice to overcome this problem and could you propose a more convenient and elegant solution?