support query validation
meodemsao opened this issue · 5 comments
meodemsao commented
i try use this lib with validate query argument but seem not work
JCMais commented
Hey @meodemsao, I will need more details/sample code to understand the issue
meodemsao commented
everything run but not return input is invalid, i using many lib but still can't valid input
maybe be cause i use with sequelize graphql
meodemsao commented
@JCMais
i using with apollo 2.x
const middleware = [yupMiddleware()]
// schema
const schema = makeExecutableSchema({
typeDefs,
resolvers,
schemaDirective: {
rateLimitDirective
}
})
const schemaWithMiddleware = applyMiddleware(schema, ...middleware)
import { resolver, createConnectionResolver } from 'graphql-sequelize'
import { validator, validate } from 'graphql-validation'
import * as yup from 'yup'
export default {
category: resolver((parent, args, context, info) => context.models.Category),
categories: {
validationSchema: yup.object().shape({
limit: yup.number().required().min(1).max(10)
}),
resolve: resolver((parent, args, context, info) => context.models.Category)
},
categoriesConnection: createConnectionResolver({
target: (parent, args, context, info) => context.models.Category,
where: (findOptions, args) => args
}).resolveConnection
}
schema.graphql
type FieldValidationError {
field: String!
errors: [String!]!
}
type MutationValidationError {
message: String!
details: [FieldValidationError!]!
}
# Write your query or mutation here
query{
categories(limit: 40){
id
name
}
}
but don't return error
JCMais commented
Hi @meodemsao, I'm not having time to look into that, however if you are able to share a full sample code, runnable, I may be able to run it locally and see If I can find what is wrong.