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 requireResolversForAllFields resolver validation option #107

Merged
merged 1 commit into from
Aug 30, 2016
Merged

Add requireResolversForAllFields resolver validation option #107

merged 1 commit into from
Aug 30, 2016

Conversation

nevir
Copy link
Contributor

@nevir nevir commented Aug 12, 2016

Asserts that all fields have a valid resolve function. This effectively disables default resolver behavior.


For example, we have a strict set of ACL decorators for our resolvers, and we want developers to be explicit about the access control for each new field they add to our schema


TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@helfer
Copy link
Contributor

helfer commented Aug 12, 2016

I think this is a great idea, but we'll need to update the docs. The way I'm understanding this option, it is intended to take precedence over the other two resolverValidationOptions, correct?

@nevir
Copy link
Contributor Author

nevir commented Aug 12, 2016

Yeah, IMO it should take precedence (and not support exclusions via the other options, if present)

@@ -279,9 +279,15 @@ function assertResolveFunctionsPresent(schema, resolverValidationOptions = {}) {
const {
requireResolversForArgs = true,
requireResolversForNonScalar = true,
requireResolversForAllFields = false,
} = resolverValidationOptions;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (requireResolversForAllFields && (! requireResolversForArgs || ! requireResolversForNonScalar)) {
  throw new Error(`Can't pass in conflicting options`)
}

@helfer
Copy link
Contributor

helfer commented Aug 19, 2016

@nevir I think it would be great if you could make the change that @alexturek proposed, but with a more useful error message that says what exactly the conflicting options are. After that I'll go ahead and merge this.

@helfer
Copy link
Contributor

helfer commented Aug 28, 2016

@nevir are you still working on this? I'd like to merge your PR as soon as it's done!

@nevir
Copy link
Contributor Author

nevir commented Aug 28, 2016

Sorry! Been distracted by other work; I'll get to this Monday morning

@nevir
Copy link
Contributor Author

nevir commented Aug 29, 2016

@helfer 👍

@helfer
Copy link
Contributor

helfer commented Aug 30, 2016

Awesome, thanks! Can you add a test just to make sure the error actually gets thrown in the right conditions? It looks like that's not tested right now.

@nevir
Copy link
Contributor Author

nevir commented Aug 30, 2016

👍 just pushed some tests

@helfer
Copy link
Contributor

helfer commented Aug 30, 2016

Perfect! We merged some other PR this morning, so you'll have to do another rebase so I can merge it.

Asserts that _all_ fields have a valid resolve function.  This effectively disables default resolver behavior.
@nevir
Copy link
Contributor Author

nevir commented Aug 30, 2016

rebased

@helfer helfer merged commit bc4e6ed into ardatan:master Aug 30, 2016
@helfer
Copy link
Contributor

helfer commented Aug 30, 2016

Awesome, thanks!

@nevir nevir deleted the nevir/require-all-fields branch August 30, 2016 23:45
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

Successfully merging this pull request may close these issues.

None yet

4 participants