Based on this https://github.com/facebook/relay/issues/1462
I have the following query in one of my components:
fragment on Viewer {
user {
events(first: 10, date: $date) {
edges {
node {
id
date
title
}
}
}
}
}
date is a DateFilter
input DateFilter {
# start date
start: String!
# end date
end: String!
}
This is the config I'm using in my relay mutation
function getConfigs(personId) {
return [
{
type: 'RANGE_ADD',
parentName: 'user',
parentID: userId,
connectionName: 'events',
edgeName: 'eventEdge',
rangeBehaviors: {
'': 'prepend',
},
},
];
}
I'm using relay compat mode
import { graphql, commitMutation } from 'react-relay/compat';
const mutation = graphql`
mutation EventAddMutation($input: EventAddInput!) {
EventAdd(input: $input) {
eventEdge {
__typename
cursor
node {
id
title
}
}
error
}
}
`;
You can do something like:
rangeBehaviors: {
'date(<insert date param here>)': 'prepend',
},
is it possible to add an edge to all connections in relay classic?
rangeBehaviors: (args) => {
return 'prepend';
},
using as a function works great
Most helpful comment
rangeBehaviors: (args) => {
return 'prepend';
},
using as a function works great