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

minField only works with scalar #211

Open
kefniark opened this issue Oct 31, 2023 · 0 comments
Open

minField only works with scalar #211

kefniark opened this issue Oct 31, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@kefniark
Copy link

Description

Earlier I was trying to use Array/List constraints but run into a problem. It works with scalar but not with objects.

input TestInput {
  id: ID!
  arrInt: [Int!] @constraint(minLength: 1) # works
  arrString: [String!] @constraint(minLength: 1) # works
  arrObj: [TestInputObj!] @constraint(minLength: 1) # doesn't work, crash
}

The documentation is not really clear if it's a design limitation, nothing specific it should only works on list of scalar.

Stacktrace

TypeError: Cannot read properties of undefined (reading 'toString')
    at getScalarType (/app/node_modules/graphql-constraint-directive/lib/type-utils.js:52:61)
    at getScalarType (/app/node_modules/graphql-constraint-directive/lib/type-utils.js:50:17)
    at getScalarType (/app/node_modules/graphql-constraint-directive/lib/type-utils.js:46:17)
    at wrapType (/app/node_modules/graphql-constraint-directive/index.js:64:20)
    at MapperKind.FIELD (/app/node_modules/graphql-constraint-directive/index.js:82:11)
    at mapFields (/app/node_modules/graphql-constraint-directive/node_modules/@graphql-tools/utils/cjs/mapSchema.js:144:37)
    at mapSchema (/app/node_modules/graphql-constraint-directive/node_modules/@graphql-tools/utils/cjs/mapSchema.js:10:37)
    at /app/node_modules/graphql-constraint-directive/index.js:77:5
    at eval (/app/apps/api/src/schema/index.ts:81:89)
@confuser confuser added the enhancement New feature or request label Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants