GraphQLSwift/GraphQL

Is there a way to validate a document with custom validation rules?

d-exclaimation opened this issue · 2 comments

Hey, I am maintaining a GraphQL server library that uses this package. I am planning to allow the user of my library to add additional custom validation rules which will be used to validate incoming requests before they are executed. My library is heavily inspired by apollo-server and looking at their approach, they are using the graphql-js validate function here.

I figured this package should also have the same function, but the only validate function that is public doesn't accept any custom rules.

I found out that the primary entry point function already perform validation but it also doesn't accept custom validation rules.

let validationErrors = validate(instrumentation: instrumentation, schema: schema, ast: documentAST)

It seemed like this library already have the function and struct needed for custom validation, but they are just not public. I am not sure if this is a intentional decision.

Hey @paulofaria, before I mash merge on this PR, was scoping the validation functions as internal an intentional decision?

@NeedleInAJayStack not that I can't remember. Probably out of habit.