-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
v7 enhance(utils) expand filterSchema #2005
Conversation
This is not the optimal way to address ardatan#1047 but is the most backwards compatible.
includes also changes to transform method arguments see ardatan#1614
* implicit pruning from healSchema and mapSchema can sometimes be dangerous: e.g. empty interfaces are valid for later extension. * the pruneSchema utility functions (and PruneSchema transform) can be explicitly used to prune as desired See: ardatan#1817
* removes support for createMergedResolver and ExtendSchema transform in favor of visitResult, simplifying the refactoring.
move typesContainSelectionSet to delegate package remove typeContainsSelectionSet
Previously, errors with invalid or missing paths were lost. See: ardatan#1641 https://github.com/apollographql/apollo-server/issues/4226 They are now saved! All correctly pathed errors are now inlined into the returned data by the CheckResultAndHandleErrors transform. The data is now annotated only with the remaining "unpathed" errors. These are then returned when possible if a null is encountered including the missing or potentially invalid path. Changes to error handling obviate some existing functions including getErrorsByPathSegment, getErrors in favor of getUnpathedErrors. Utility functions including slicedError and unreleased functions extendedError and unextendedError are no longer necessary.
we could consider later adding support for $$asyncIterable similar to upstream graphql-js, but this would have to be across the entire codebase, which currently supports only Symbol.asyncIterator.
use delegationContext within delegation transforms remove fragment hints and transforms in favor of selection set hints and transforms prune fragment functions from utils package
@yaacovCR would you be onboard with this as part of v7? We use this behavior at Vox Media, would be nice to backfill it into the base package. Type/field/arg filtering is really useful when whitelisting parts of a schema based on access level. |
This is not the optimal way to address ardatan#1047 but is the most backwards compatible.
includes also changes to transform method arguments see ardatan#1614
* implicit pruning from healSchema and mapSchema can sometimes be dangerous: e.g. empty interfaces are valid for later extension. * the pruneSchema utility functions (and PruneSchema transform) can be explicitly used to prune as desired See: ardatan#1817
* removes support for createMergedResolver and ExtendSchema transform in favor of visitResult, simplifying the refactoring.
move typesContainSelectionSet to delegate package remove typeContainsSelectionSet
Previously, errors with invalid or missing paths were lost. See: ardatan#1641 https://github.com/apollographql/apollo-server/issues/4226 They are now saved! All correctly pathed errors are now inlined into the returned data by the CheckResultAndHandleErrors transform. The data is now annotated only with the remaining "unpathed" errors. These are then returned when possible if a null is encountered including the missing or potentially invalid path. Changes to error handling obviate some existing functions including getErrorsByPathSegment, getErrors in favor of getUnpathedErrors. Utility functions including slicedError and unreleased functions extendedError and unextendedError are no longer necessary.
we could consider later adding support for $$asyncIterable similar to upstream graphql-js, but this would have to be across the entire codebase, which currently supports only Symbol.asyncIterator.
use delegationContext within delegation transforms remove fragment hints and transforms in favor of selection set hints and transforms prune fragment functions from utils package
Can you rebase on master now that #1989 merged |
💥 No ChangesetLatest commit: e2d93fe Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
Not sure what's going on with branching here... a rebase encounters all kinds of conflicts, and I'm not sure why. This is at least the intended diff, though commit history looks weird. |
f53017d
to
9cbe464
Compare
* updated filter schema. * update existing usage.
* updated filter schema. * update existing usage.
* updated filter schema. * update existing usage.
* updated filter schema. * update existing usage.
* updated filter schema. * update existing usage.
This enhances the
utils/filterSchema
method to make it more general purpose and efficient. Right now the method is not quite granular enough to be useful for access control filtering. This updates the method as follows:Adds dedicated filters for object fields, interface fields, and input fields; while leaving one general purpose field filter option that will operate across all three.
Adds argument filtering, which is extremely useful when performing access control on a schema for certain audiences.
Makes all but the type filter optional. When a filter is omitted, the method skips churning through that set of work.
Release Notes
BREAKING –
filterSchema(fieldFilter)
option will now filter ALL fields across Object, Interface, and Input types. For the previous Object-only behavior, switch to theobjectFieldFilter
option.TODO: