amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

Not able to filter based on boolean and integer values when using generateClient from 'aws-amplify/data'

Open sushpatg opened this issue 1 year ago • 0 comments

Environment information

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 299.08 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.11.1 - /opt/homebrew/opt/node@20/bin/node
  Yarn: undefined - undefined
  npm: 10.2.4 - /opt/homebrew/opt/node@20/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.0
  @aws-amplify/backend-cli: 1.0.1
  aws-amplify: 6.2.0
  aws-cdk: 2.139.1
  aws-cdk-lib: 2.139.1
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

I was trying to perform listTodo filtering based on a boolean value and seeing unexpected behaviour where its looking string value for both boolean and Integer fields

  Todo: a
    .model({
      content: a.string(),
      done: a.boolean(),
      count:a.integer(),

      priority: a.enum(['low', 'medium', 'high'])
    })
    .authorization((allow) => [allow.guest()]),
});

Query:

const { data } = await client.models.Todo.list({
      filter:{
        content :{ eq:"test"},
        done:{eq: false},
        count:{eq: 12}
      }
    });

Error : Type 'boolean' is not assignable to type 'string' Type 'number' is not assignable to type 'string'

This is not the behavior when using v5r or v6 code of 'aws-amplify/api'

sushpatg avatar May 02 '24 16:05 sushpatg