Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Determine how to model one-to-many relationships #92

Open
alastair opened this issue Feb 26, 2020 · 1 comment
Open

Determine how to model one-to-many relationships #92

alastair opened this issue Feb 26, 2020 · 1 comment
Labels
modelling question Further information is requested

Comments

@alastair
Copy link
Member

We have a few cases where we want to model a one-to-many relationship.

  • EntryPoint#potentialAction
  • DefinedTerm#inDefinedTermSet

Using the neo4j-graphql-js library we haven't found a good way to do this. Currently we use @relation to define a many-to-many relationship.

@ChristiaanScheermeijer suggested that we could try and use Neo4j constraints. We need to see if this is a suitable solution.

https://github.com/trompamusic/ce-api/pull/90/files/123f1a4849e69dde82543d77dc224d9ac0c8cf2e#r384462860

@alastair
Copy link
Member Author

We found that you can make a relation for a single item:

target: ThingInterface! @relation(name: "ANNOTATION_TARGET", direction: OUT)

However, in the case where a field is required and a relation, the Create mutation allows you to create an object without the field (because you need to use Add/Merge to create the relation), but if you try and do a Query that includes this field when it's not set an error will be raised.
This can probably be closed if we're happy with the current solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modelling question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants