I am starting to develop for relay coming from Apollo. I have a dumb server running on a SQLITE3 database just for testing while I am refactoring. Using graphql-relay on the backen.
Currently I have something like this:
{
root: {
allFoo: [FooType]
}
}
I was wondering how I would add a new FooType item to the allFoo list. On the getConfigs the RANGE_ADD only acts upon connections. So do I need to make my allFoo type a connection instead of a GraphqlList(FooType) ? Or can I use FIELD_CHANGE somehow?
Take a look at this example: https://github.com/bfwg/relay-gallery/blob/master/frontend/src/app/mutation/AddImageMutation.js#L47
The below example is a demo on how to add an image to the image list.
getConfigs() {
return [{
type: 'RANGE_ADD',
parentName: 'User',
parentID: this.props.images.id,
connectionName: 'images',
edgeName: 'newImageEdge',
rangeBehaviors: {
'': 'prepend',
},
}];
}
Hope this helps!