Skip to content

Add support for custom validation rules in apollo-language-server #1056

@JakeDawkins

Description

@JakeDawkins

Inspired by #800

NOTE: I won't be personally building this anytime soon. I WILL, however, gladly review any pull requests that adds this feature 😄

Right now, the apollo-language-server runs a set of validation rules against operations (great, right??).

In certain circumstances (like if you're running a relay project), you may want to disable existing validations or add new ones (like requiring an id on every object type for caches).

Since the apollo.config.js is an executable file, not just a static configuration, we can actually add these validations to it to run against client projects!

Here's my proposed API:

// apollo.config.js
const { defaultValidationRules } = require('apollo/lib/defaultValidationRules')
const relayValidationRules = require('my-custom-validation-rules')

module.exports = {
  client: {
    validationRules: [
		relayValidationRules,
		...defaultValidationRules.filter(removeBitsThatMessUpRelay)
	]
  }
}

This way, you'd have full control (for better or worse 😉) over validation rules, rather than just enabling/disabling rules from graphql-js


This would require changes to:

  • apollo-language-server
    • add validation overrides to the config/validation
  • apollo
    • export the default validation rules for easy import

Metadata

Metadata

Assignees

Labels

🔨 clirelated to the CLI itself🗒️ component - vscoderelated to editor tooling🎉 featureNew addition or enhancement to existing solutions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions