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

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

Closed
JakeDawkins opened this issue Feb 26, 2019 · 1 comment · Fixed by #1288
Closed

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

JakeDawkins opened this issue Feb 26, 2019 · 1 comment · Fixed by #1288
Assignees
Labels
🔨 cli related to the CLI itself 🗒️ component - vscode related to editor tooling 🎉 feature New addition or enhancement to existing solutions

Comments

@JakeDawkins
Copy link
Contributor

JakeDawkins commented Feb 26, 2019

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
@JakeDawkins JakeDawkins added 🔨 cli related to the CLI itself 🎉 feature New addition or enhancement to existing solutions 🗒️ component - vscode related to editor tooling discussion ☕ labels Feb 26, 2019
@JakeDawkins JakeDawkins self-assigned this Feb 26, 2019
alloy added a commit to alloy/apollo-tooling that referenced this issue May 21, 2019
alloy added a commit to alloy/apollo-tooling that referenced this issue May 21, 2019
alloy added a commit to alloy/apollo-tooling that referenced this issue May 21, 2019
alloy added a commit to alloy/apollo-tooling that referenced this issue May 21, 2019
@alloy
Copy link
Contributor

alloy commented May 21, 2019

Created a new PR #1288

alloy added a commit to alloy/apollo-tooling that referenced this issue May 23, 2019
alloy added a commit to alloy/apollo-tooling that referenced this issue May 24, 2019
trevor-scheer pushed a commit that referenced this issue May 30, 2019
* [language server] Allow configuration of validation rules.

* [language server] Allow filtering of default validation rules

Closes #1056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 cli related to the CLI itself 🗒️ component - vscode related to editor tooling 🎉 feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants