relay: rangeBehaviors should be a function that returns a GraphQLMutatorConstants.RANGE_OPERATION
As mentioned by @johanobergman in #604 and similar to what @AndrewIngram proposed in #538, let’s make rangeBehaviors
a function that receives the connection arguments and returns one of GraphQLMutatorConstants.RANGE_OPERATIONS
.
getConfigs: [{
/* ... */
rangeBehaviors(
fieldArgs: {[argName: string]: argValue: string}
): ?$Enum<typeof GraphQLMutatorConstants.RANGE_OPERATIONS> {
return isBefore(fieldArgs.startDate, fieldArgs.endDate) ?
GraphQLMutatorConstants.RANGE_OPERATIONS.APPEND :
GraphQLMutatorConstants.RANGE_OPERATIONS.PREPEND;
}
/* ... */
}]
Add an appropriate deprecation warning to RelayDeprecated
.
Bonus: write a jscodeshift codemod that will mod this:
rangeBehaviors: {
'foo(true)': 'prepend',
'foo(false)': 'append',
}
…to this:
rangeBehaviors({foo}) {
if (foo === true) {
return 'prepend';
} else if (foo === false) {
return 'append';
}
}
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (10 by maintainers)
Commits related to this issue
- Replace the “unsorted range behavior key” warning with an invariant Summary: We said that we were going to remove this in v0.5 Reviewed By: kassens Differential Revision: D2672824 fb-gh-sync-id: e... — committed to facebook/relay by steveluscher 9 years ago
- allow rangeBehaviors to be defined as a function Summary: New PR for #639 Fix for #615, proposed in #538 Allows `rangeBehaviors` to be defined as a function that receives the connection arguments an... — committed to facebook/relay by xuorig 8 years ago
@brysgo Good catch, @xuorig has put up #1216 to address this.