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

Filtering by IDFilterComparison: String value from type converted to NaN #1557

Open
shirados90 opened this issue Nov 6, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@shirados90
Copy link

Describe the bug
Searching by ID field fails if non-numeric string passed as value.

example query:

query GetComponents($projId: ID!) {
components(filter: { projectId: { eq: $projId } }) {
edges {
node {
id
name
}
}
}
}
input ComponentFilter {
and: [ComponentFilter!]
or: [ComponentFilter!]
id: IDFilterComparison
name: StringFieldComparison
projectId: StringFieldComparison
project: ComponentFilterProjectFilter
}

In query-service a query argument looks like the following:

{ filter: { projectId: { eq: NaN } } }

@entity({ name: 'Component' })
export class ComponentEntity {
@PrimaryGeneratedColumn()
id: number;

@column()
name: string;

@manytoone(() => ProjectEntity, { cascade: true, nullable: false })
project: ProjectEntity;

@column('uuid')
@RelationId((c: ComponentEntity) => c.project)
projectId: string;
}

@ObjectType('Component')
@FilterableRelation('project', () => ProjectDTO, {
disableRemove: true,
disableUpdate: true,
nullable: false
})
export class ComponentDTO {
@IDField(() => ID)
id!: number;

@FilterableField()
name!: string;

@IDField(() => ID)
projectId!: string;
}

To Reproduce

  1. Setup project with MySQL, TypeORM, Nestjs-query
  2. Use Autoresolvers, autoservices (follow get-started guide)
  3. Create entity with uuid id
  4. Create ManyToOne relation with explicit foreign key
  5. Create DTO relations
  6. Try to search by any of field attributed with ID

Expected behavior
GQL ID type treated as string, not number.

Desktop (please complete the following information):
`
{
"name": "smart-flow",
"packageManager": "[email protected]",
"dependencies": {
"@apollo/client": "^3.7.1",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@fontsource/roboto": "^4.5.8",
"@inovua/reactdatagrid-community": "^5.5.0",
"@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.12",
"@nestjs-query/query-graphql": "^0.30.0",
"@nestjs-query/query-typeorm": "^0.30.0",
"@nestjs/apollo": "^10.1.4",
"@nestjs/common": "^9.1.6",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.0",
"@nestjs/graphql": "^10.1.5",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/typeorm": "^9.0.1",
"@reach/menu-button": "^0.18.0",
"@reduxjs/toolkit": "^1.8.6",
"@tailwindcss/forms": "^0.5.3",
"apollo-server-express": "^3.11.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"core-js": "^3.26.0",
"dataloader": "^2.1.0",
"flowbite": "^1.5.3",
"flowbite-react": "^0.3.4",
"graphql": "^16.6.0",
"graphql-subscriptions": "^2.0.0",
"mysql2": "^2.3.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.2",
"reactflow": "^11.2.0",
"reflect-metadata": "^0.1.13",
"regenerator-runtime": "^0.13.10",
"rxjs": "^7.0.0",
"typeorm": "^0.3.10"
},
"devDependencies": {
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@nrwl/jest": "15.0.9",
"@nrwl/linter": "^15.0.4",
"@nrwl/nest": "15.0.9",
"@nrwl/node": "15.0.9",
"@nrwl/nx-cloud": "^15.0.0",
"@nrwl/react": "^15.0.4",
"@nrwl/webpack": "^15.0.4",
"@testing-library/react": "^13.4.0",
"@types/jest": "28.1.1",
"@types/node": "18.7.1",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"autoprefixer": "10.4.12",
"eslint": "^8.26.0",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"nx": "^15.0.4",
"postcss": "8.4.16",
"tailwindcss": "3.1.8",
"ts-jest": "28.0.5",
"ts-node": "10.9.1",
"tslib": "^2.4.0",
"typescript": "^4.8.4"
}
}

`

@shirados90 shirados90 added the bug Something isn't working label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant