I'm currently trying to have two fields related to...
# prisma-whats-new
p
I'm currently trying to have two fields related to the same user model. one is the "creator" and one the "owner" - but i receive an error message, that this cant be done, due to a field already existing.
m
Could you share your datamodel 😄
j
Have you explicitly named the relations? This information might be useful… Using the name argument of the @relation directive In certain cases, your data model may contain ambiguous relations. For example, consider you not only want a relation to express the “author-relationship” between User and Story, but you also want a relation to express which Story nodes have been liked by a User. In that case, you end up with two different relations between User and Story! In order to disambiguate these, you now need the name argument from the @relation directive:
Copy code
type User {
  id: ID! @unique
  writtenStories: [Story!]! @relation(name: "WrittenStories")
  likedStories: [Story!]! @relation(name: "LikedStories")
}

type Story {
  id: ID! @unique
  text: String!
  author: User! @relation(name: "WrittenStories")
  likedBy: [User!]! @relation(name: "LikedStories")
}
If the name wasn’t provided in this case, there would be now way for Graphcool to know whether writtenStories should relate to the author or the likedBy field.
p
hey @matic Datamodel: type Idea @model { id: ID! @isUnique createdAt: DateTime! updatedAt: DateTime! title: String! #Name of the idea #Content for handover trends: String problem: String solution: String vision: String #Grand vision customerConnection: String competition: String market: String #GTD Admin createdBy: User! @relation(name: "IdeaCreator") owner: User! @relation(name: "UserIdea") asignedCustomer: Customer! @relation(name: "CustomerIdeas") #Currently for which customer tags: [Tags!]! @relation(name: "IdeaTags") processStatus: [IdeaProcessStatus!]! @relation(name: "IdeaProcessStatusUpdate") #GTD Weekly Customer Update weeklyStatus:[IdeaWeeklyStatus!]! @relation(name: "IdeaIdeaWeeklyStatus") } type User @model { # Required system field: id: ID! @isUnique # read-only (managed by Graphcool) # Optional system fields (remove if not needed): createdAt: DateTime! # read-only (managed by Graphcool) updatedAt: DateTime! # read-only (managed by Graphcool) createdIdeas: [Idea!]! @relation(name: "IdeaCreator") ownedIdeas: [Idea!]! @relation(name: "UserIdea") createdTags: [Tags!]! @relation(name: "TagCreator") createdIdeaWeeklyStatus: [IdeaWeeklyStatus!]! @relation(name: "IdeaWeeklyStatusUser") createdProcessStatusUpdate: [IdeaProcessStatus!]! @relation(name: "ProcessStatusUpdateUser") loginSub: String @isUnique name: String email: String username: String profilImage: String auth0UserId: String @isUnique }
j
This was a snippet from here: https://www.graph.cool/docs/1.0/reference/database/data-modelling-(sdl)-eiroozae8u#the-@relation-directive specifically the “*using the
name
argument of the
@relation
direction*” section
p
@JR Leonard I always use the "name" argument for @relation 😕. I'll deploy to a new target and see what happens
j
@P_loringhoven ahhhh sorry, I had just read about this yesterday so it was fresh in my brain lol
p
Ok lol... Deployed to a new Target with GraphCool CLI 1.0 worked...
👍 1
-.-'
m
great! 😄
p
Yes, but no freaking clue why - and dont want to dig into the core code now 😄
j
lol