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
89 stars 76 forks source link

Generated ModelSubscriptionFilterInput missing readOnly/implicit fields #1252

Open iartemiev opened 1 year ago

iartemiev commented 1 year ago

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

10.7.2

What operating system are you using?

macOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

A model schema with implicit fields such as

type Todo @model @auth(rules: [ { allow: owner } ]) {
  id: ID!
  name: String!
  description: String
}

Gets transformed into the following generated schema

type Todo {
  id: ID!
  name: String!
  description: String
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
  _version: Int!
  _deleted: Boolean
  _lastChangedAt: AWSTimestamp!
  owner: String
}

And corresponding filter input:

input ModelSubscriptionTodoFilterInput {
  id: ModelSubscriptionIDInput
  name: ModelSubscriptionStringInput
  description: ModelSubscriptionStringInput
  and: [ModelSubscriptionTodoFilterInput]
  or: [ModelSubscriptionTodoFilterInput]
}

The filter input is missing readOnly timestamps, as well as the implicitly-defined owner field. This prevents clients from filtering subscriptions on these fields.

Expected behavior

Include implicit fields in the filter input:

input ModelSubscriptionTodoFilterInput {
  id: ModelSubscriptionIDInput
  name: ModelSubscriptionStringInput
  description: ModelSubscriptionStringInput
  createdAt: ModelSubscriptionStringInput
  updatedAt: ModelSubscriptionStringInput
  owner: ModelSubscriptionStringInput
  and: [ModelSubscriptionTodoFilterInput]
  or: [ModelSubscriptionTodoFilterInput]
}

Reproduction steps

  1. Add model with implicit fields to schema
  2. amplify api gql-compile
  3. Inspect generated filter input

Project Identifier

No response

Log output

No response

Additional information

No response

Before submitting, please confirm:

AnilMaktala commented 1 year ago

As I can replicate this problem, I will label it as a bug.