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

support query validation #4

Open
meodemsao opened this issue Oct 29, 2019 · 5 comments
Open

support query validation #4

meodemsao opened this issue Oct 29, 2019 · 5 comments

Comments

@meodemsao
Copy link

i try use this lib with validate query argument but seem not work

@JCMais
Copy link
Owner

JCMais commented Oct 29, 2019

Hey @meodemsao, I will need more details/sample code to understand the issue

@meodemsao
Copy link
Author

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
Copy link
Author

meodemsao commented Nov 16, 2019

@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
Copy link
Owner

JCMais commented Nov 18, 2019

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.

@meodemsao
Copy link
Author

@JCMais thank, i using graphql-shield for my project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants