$input syntax in the codegen mutations is not working with graphqlOperations.
See original GitHub issueDescribe the bug Running amplify codegen creating mutations not supported by amplify graphqlOperations
To Reproduce amplify codegen creates mutations like this:
export const CreateCity = gql`
mutation CreateCity($input: CreateCityInput!) {
createCity(input: $input) {
id
city_name
zip_code
}
}
`;
However when I try to use it via this : ` API.graphql(graphqlOperation(gqlToString(fp_mutations.CreateCity, {id: {city_name:city_name,zip_code:zip_code}})))
I get an error
path: null, locations: Array(1), message: “Variable ‘input’ has coerced Null value for NonNull type ‘CreateCityInput!’”
However if I change the mutation by hand to something like this :
export const CreateCity = mutation createCity($city_name: String!, $zip_code: String!) { createCity(input: {city_name: $city_name, zip_code: $zip_code}) { id, city_name, zip_code } }
;
`
and call it like this
API.graphql(graphqlOperation(gqlToString(fp_mutations.CreateCity, {city_name:city_name,zip_code:zip_code})))
it works! It seems that the ($input syntax in the codegen mutations is not working with graphqlOperations.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
@lahirian the mutation expects an
input
object which wrapscity_name
andzip_code
. The update code would look like below:This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels for those types of questions.