1

I have two databases/models User and Listing.

I am trying to create two relations:

  • One User to one Listing called "ListingOwner"
  • One User to many Listing called "ListingCreator"

My users can create multiple listings. I want to keep that as "Creator". But any user is allowed to come in and "claim" a listing, making them the "Owner". However in graph.cool I can't create more then one relationshp between User and Listing model, it gives me this error:

https://i.stack.imgur.com/r8elX.png

Server request for mutation AddRelationMutation failed for the following reasons: 1. A field with the name 'listing' already exists AddRelationInput!) {addRelation(input:$input_0) {clientMutat ^^^

Noitidart
  • 35,443
  • 37
  • 154
  • 323

1 Answers1

3

A model can only have one field with a given name. In your case the solution would be to rename one of the listing fields to something else. When you create the relation you can change the field name in the ui as below:

enter image description here

Hope that helps :-)

sorenbs
  • 749
  • 4
  • 7
  • Very interesting thank you @sorenbs! The screenshot was especially helpful! As otherwise I wouldn't have known what that meant, I am very new to graphql. Thanks sir! – Noitidart Feb 08 '17 at 22:15
  • 2
    Your welcome Notidart :-) Keep asking questions as you explore GraphQL! – sorenbs Feb 09 '17 at 10:48