简体   繁体   中英

GraphQL Relay relationships and mutation

I'm very confused regarding the the relations in GraphQL-Relay. When its about one-to-many it seems very straightforward. I created some connectionDefinitions and it worked perfectly. But I have the following case where I would like to create / update the model below.

new Schema({
    item: {type: String, ref: ‘Item’, required: true},
    user: {type: String, ref: ‘User’, required: true},
    liked: {type: Boolean, required: true, default: false}
})

Should I create a connection with User and Item in my GraphQL Schema?

If I look at the config for 'RANGE_ADD' it shows parentName and parentId but in my case I have more than one parent. Should I have two objects configuration (one for each parent) in my getConfigs array?

Can I create and update this object without a connection?

Thanks

Should I create a connection with User and Item in my GraphQL Schema?

Not necessary as relations are more for one-to-many and my interaction object has to one-to-one relations. Connections are useful for pagination

Which getConfigs should I use?

RANGE_ADD is the appropriate configuration to create and delete. Only one configuration is enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM