variable used in position expecting type value_String_NotNull_maxLength_255
roshal opened this issue · 2 comments
roshal commented
had to comment out all constraints after updating config according to new readme :(
i want to use String
type in request but not an arbitrary value_String_maxLength_255
### graphql-constraint-directive
directive @constraint(
uniqueTypeName: String
# string
contains: String
endsWith: String
format: String
maxLength: Int
minLength: Int
notContains: String
pattern: String
startsWith: String
# number
exclusiveMax: Float
exclusiveMin: Float
max: Float
min: Float
multipleOf: Float
) on INPUT_FIELD_DEFINITION
input SomeInput {
value: String @constraint(maxLength: 255)
}
config below works improperly
import {GraphQLFileLoader} from '@graphql-tools/graphql-file-loader'
import {constraintDirective} from 'graphql-constraint-directive'
import {loadSchemaSync} from '@graphql-tools/load'
import {makeExecutableSchema} from '@graphql-tools/schema'
import resolvers from '@/resolvers'
const loaders = [
new GraphQLFileLoader(),
]
const typeDefs = loadSchemaSync('source/schema/**/*.graphql', {
loaders,
})
const schemaTransforms = [
constraintDirective(),
]
const schema = makeExecutableSchema({
resolvers,
schemaTransforms,
typeDefs,
} as any)
export default schema
config below does not work
import {GraphQLFileLoader} from '@graphql-tools/graphql-file-loader'
import {constraintDirective} from 'graphql-constraint-directive'
import {loadSchemaSync} from '@graphql-tools/load'
import {makeExecutableSchema} from '@graphql-tools/schema'
const loaders = [
new GraphQLFileLoader(),
]
const typeDefs = loadSchemaSync('source/schema/**/*.graphql', {
loaders,
})
const schema = makeExecutableSchema({
resolvers,
typeDefs,
})
export default constraintDirective()(schema)
confuser commented
Based on the stack trace it appears you're using graphql v15. You need to downgrade to v2 of this package, as v3 supports apollo v3 & graphql v16+ only. I'll update the readme to make that clearer