aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Graphql makes error when returned list's length is 1 #7796

Closed seyoongit closed 1 year ago

seyoongit commented 3 years ago

The code to reproduce this error looks like below:

schema.graphql

schema.graphql


handler returns Integer Array which length is 1

스크린샷 2021-02-22 오후 6 35 31


I invoked graphql query in amplify-mock console http://10.220.190.149:20002/

스크린샷 2021-02-22 오후 6 36 44


It returns array of null which length is 5.

when value is 7, it will returns array of null which length is 7. when 123, Array of null which length is 123 on and on. 스크린샷 2021-02-22 오후 6 39 31


when returned array's length is equal or bigger than 2, it works well as expected

스크린샷 2021-02-22 오후 6 40 11


스크린샷 2021-02-22 오후 6 40 23

sammartinez commented 3 years ago

@seyoongit Thanks for cutting this issue, can you provide us more information? Are you using this directly with Amplify JavaScript, Amplify Console, etc. Also, can you provide your package.json along with your environment settings?

Please use the follow command:

npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages

Thanks ahead of time!

seyoongit commented 3 years ago

sorry for late.

currently I'm using Amplify-Javascript (for web).

npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages

System: OS: macOS 10.15.7 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 166.32 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.19.1 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Browsers: Edge: 89.0.774.48 Firefox: 83.0 Safari: 14.0 npmPackages: @aws-amplify/ui-react: ^0.2.34 => 0.2.34 @material-ui/core: 4.9.14 => 4.9.14 @material-ui/icons: 4.9.1 => 4.9.1 aws-amplify: ^3.3.14 => 3.3.14 aws-appsync: ^4.0.2 => 4.0.2 chartist: 0.10.1 => 0.10.1 classnames: 2.2.6 => 2.2.6 gatsby: ^2.25.3 => 2.31.0 gatsby-image: ^2.4.21 => 2.10.0 gatsby-plugin-manifest: ^2.5.2 => 2.11.0 gatsby-plugin-offline: ^3.3.3 => 3.9.0 gatsby-plugin-react-helmet: ^3.3.14 => 3.9.0 gatsby-plugin-root-import: ^2.0.5 => 2.0.5 gatsby-plugin-sharp: ^2.7.1 => 2.13.0 gatsby-source-filesystem: ^2.4.2 => 2.10.0 gatsby-transformer-sharp: ^2.5.21 => 2.11.0 graphql: ^15.4.0 => 15.4.0 graphql-tag: ^2.11.0 => 2.11.0 history: 4.10.1 => 4.10.1 match-sorter: 4.1.0 => 4.1.0 moment: ^2.29.1 => 2.29.1 net: ^1.0.2 => 1.0.2 node-sass: 4.14.1 => 4.14.1 nouislider: 14.5.0 => 14.5.0 perfect-scrollbar: 1.5.0 => 1.5.0 prettier: 2.1.2 => 2.1.2 prop-types: ^15.7.2 => 15.7.2 random-words: ^1.1.1 => 1.1.1 react: 16.13.1 => 16.13.1 react-big-calendar: 0.24.6 => 0.24.6 react-bootstrap-sweetalert: 5.1.9 => 5.1.9 react-chartist: 0.14.3 => 0.14.3 react-datetime: 2.16.3 => 2.16.3 react-dom: 16.13.1 => 16.13.1 react-google-maps: 9.4.5 => 9.4.5 react-helmet: ^6.1.0 => 6.1.0 react-icons: ^3.11.0 => 3.11.0 react-jvectormap: 0.0.16 => 0.0.16 react-router-dom: 5.2.0 => 5.2.0 react-scripts: 3.4.1 => 3.4.1 react-spring: ^8.0.27 => 8.0.27 react-swipeable-views: 0.13.9 => 0.13.9 react-table: 7.1.0 => 7.1.0 react-tagsinput: 3.19.0 => 3.19.0 styled-components: ^5.2.1 => 5.2.1 npmGlobalPackages: @aws-amplify/cli: 4.29.8 gulp: 4.0.2 nodemon: 2.0.4 npm: 6.14.8

package.json

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "@aws-amplify/ui-react": "^0.2.34",
    "@material-ui/core": "4.9.14",
    "@material-ui/icons": "4.9.1",
    "aws-amplify": "^3.3.14",
    "aws-appsync": "^4.0.2",
    "chartist": "0.10.1",
    "classnames": "2.2.6",
    "gatsby": "^2.25.3",
    "gatsby-image": "^2.4.21",
    "gatsby-plugin-manifest": "^2.5.2",
    "gatsby-plugin-offline": "^3.3.3",
    "gatsby-plugin-react-helmet": "^3.3.14",
    "gatsby-plugin-root-import": "^2.0.5",
    "gatsby-plugin-sharp": "^2.7.1",
    "gatsby-source-filesystem": "^2.4.2",
    "gatsby-transformer-sharp": "^2.5.21",
    "graphql": "^15.4.0",
    "graphql-tag": "^2.11.0",
    "history": "4.10.1",
    "match-sorter": "4.1.0",
    "moment": "^2.29.1",
    "net": "^1.0.2",
    "node-sass": "4.14.1",
    "nouislider": "14.5.0",
    "perfect-scrollbar": "1.5.0",
    "prop-types": "^15.7.2",
    "random-words": "^1.1.1",
    "react": "16.13.1",
    "react-big-calendar": "0.24.6",
    "react-bootstrap-sweetalert": "5.1.9",
    "react-chartist": "0.14.3",
    "react-datetime": "2.16.3",
    "react-dom": "16.13.1",
    "react-google-maps": "9.4.5",
    "react-helmet": "^6.1.0",
    "react-icons": "^3.11.0",
    "react-jvectormap": "0.0.16",
    "react-router-dom": "5.2.0",
    "react-scripts": "3.4.1",
    "react-spring": "^8.0.27",
    "react-swipeable-views": "0.13.9",
    "react-table": "7.1.0",
    "react-tagsinput": "3.19.0",
    "styled-components": "^5.2.1"
  },
  "devDependencies": {
    "prettier": "2.1.2"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "0BSD",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

chrisbonifacio commented 3 years ago

Hi :wave: Sorry this was auto-closed by stale bot. We are working towards preventing this from happening in the future.

I noticed that in your schema you have lowercase [int] instead of capitalized [Int]. Did you correct this afterwards because that schema would not compile for mocking and would return this error.

Failed to start API Mock endpoint Error: Unknown type "int". Did you mean "Int" or "BigInt"?

chrisbonifacio commented 1 year ago

Closing this as stale as we don't have enough information to consistently reproduce. If you are still experiencing this issue in the latest version of the Amplify CLI, aws-amplify js library, and a graphql transformer v2 schema please open a new issue with steps to reproduce.