Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Cannot generate multi-type relationships #201

Closed
MuddyBootsCode opened this issue Feb 19, 2019 · 5 comments · Fixed by #481
Closed

Cannot generate multi-type relationships #201

MuddyBootsCode opened this issue Feb 19, 2019 · 5 comments · Fixed by #481

Comments

@MuddyBootsCode
Copy link

MuddyBootsCode commented Feb 19, 2019

type Created @relation(name: "CREATED_BY"){
  from: User
  to: Tract, Well, SWD, Operator
  date: Date
}

It's not currently possible to designate a relationship to multiple node types in a manner like that shown above.

@emregency
Copy link

@MuddyBootsCode I think that is typically a union type.

Some exemples below:
https://www.apollographql.com/docs/apollo-server/features/unions-interfaces.html

@hataraxy
Copy link

I've tested union in order to make the relationship mutations working but it was KO.
#130 Feature Request: Union type support
Also if fixed, this may answer your needs too :
#182 [Question/Suggestion] Autogeneration of Mutations for relations to Interface types

@MuddyBootsCode
Copy link
Author

I've ended up going the interface route.

interface Alert {
    id: ID!
    title: String
    text: String
}

type LeaseAlert implements Alert {
    id: ID!
    title: String
    text: String
    lease: Lease @relation(name: "ALERT", direction: "OUT")
}

type TractAlert implements Alert {
    id: ID!
    title: String
    text: String
    tract: Tract @relation(name: "ALERT", direction: "OUT")
}

It's working so far but it'd be nice to have something less verbose.

@benjamin-rood
Copy link

Interface isn't a fit for relationships between types that don't share mostly identical fields.

@optimuspaul
Copy link

Also no solution that supports edges with properties

The positions field on the Device node type uses the Position relationship type but Position comes from Positionable and goes to CoordinateSpace

Positionable is an interface that Device implements. Position is a relation that has properties and needs properties.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants