aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
88 stars 76 forks source link

Mutation arguments does not accept customType #2705

Open OperationalFallacy opened 2 months ago

OperationalFallacy commented 2 months ago

Environment information

latest packages

Description

In gen1 I could do this

input UserInput {
  securityId: ID!
  docId: someEnum
}

type Mutation {
  requestOperation(input: UserInput!): Document // input is a custom type and output is a model

Gen2 shows an error if I use custom type in the arguments

requestOperation a
.mutation()
.arguments({
  input: a.ref("UserInput")
})

It was convenient since front-end would get strongly typed, separate interfaces for the input

ykethan commented 2 months ago

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

chrisbonifacio commented 2 months ago

Hi @OperationalFallacy this is currently expected behavior. Using a.ref does not dereference model fields when passed to custom query/mutation arguments.you have to explicitly list the fields. Same with referencing an enum, online inline enums are supported.

I will mark this as a feature request for the team to consider.