Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation arguments does not accept customType #441

Open
OperationalFallacy opened this issue Jul 12, 2024 · 3 comments
Open

Mutation arguments does not accept customType #441

OperationalFallacy opened this issue Jul 12, 2024 · 3 comments
Assignees

Comments

@OperationalFallacy
Copy link

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
Copy link
Member

ykethan commented Jul 12, 2024

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

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Jul 12, 2024
@chrisbonifacio chrisbonifacio self-assigned this Jul 15, 2024
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Jul 15, 2024

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.

@chrisbonifacio chrisbonifacio added the feature-request New feature or request label Jul 15, 2024
@kfinley-rbi
Copy link

kfinley-rbi commented Oct 10, 2024

Hi @chrisbonifacio,

I think we might have raised a duplicate here:
#435

What would be the work around if we nested arrays what we want to pass to an AppSync resolver or lambda?

Item: a.customType({
  modifiers: a.string().array(),
}),

updateItems: a
  .mutation()
  .arguments({
    items: a.ref('Item').array(),
  })

We could flatten it, but then we would need to track the relations relationships manually.

updateItems: a
.mutation()
.arguments({
  items: a.string().array(),
  modifiers: a.string().array(),
})

All suggestions would be helpful. Thank you!

@stocaaro stocaaro transferred this issue from aws-amplify/amplify-category-api Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants