-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Relationship CRUD #14
Comments
Can you provide an example type (in GraphQL) for the Manager and Department, I'm interested to see how it would look with the relationship fields and how filtering would work between these. |
This would be, for example: type Department {
name: String!,
...
manager: DepartmentManager
}
type DepartmentManager {
name: String!,
...
department: Department
} Of course there's no filtering available for this as both are unique entity relationships. In case Department to DepartmentManager was OneToMany it would be like this: type Department {
name: String!,
...
manager(where: DepartmentManagerBoolExp, limit: Int): [DepartmentManager!]
}
type DepartmentManager {
name: String!,
...
department: Department
} |
In addition to this, the resulting edge names will have __edge as suffix to prevent overlapping with existing collections, in this example, department_managers (the edge) would overlap with the entity. So with this changes these are the new relationship definitions: Manager property on Department entity {
"name": "manager",
"edge": "department_managers__edge",
"from": "departments",
"to": "department_managers",
"type": "one_to_one",
"direction": "inbound"
} Department property on Manager entity {
"name": "department",
"edge": "department_managers__edge",
"from": "department_managers",
"to": "departments",
"type": "one_to_one",
"direction": "outbound"
} |
Preliminary checklist
Problem
Right now there's no way to actually create, read, update and delete relationships for existing entities.
Solution
The solution for this issue is implementing new dynamic queries and mutations based on the database structure. Depending on the relationship type different solutions are provided.
Progress
One to one
Example: on this example there's an entity being Department, and another being Manager, and a relationship one to one between those two entities called DepartmentManager.
Structure
Department
DepartmentManager
Department
toDepartmentManager
| NOTE: With the current system the edge name resulting from the creation through the meta API would bedepartment_department_managers
which is not accurate. To avoid these names we would have to do some kind of special namings for edges, prompting it to the user, for example, he would setfrom
and theto
collections on the meta API, if there's overlapping on the name, we would remove the overlapped word, making the resulting edge name: department_department_manager →department_managers
Edge definitions
Manager property on Department entity
Department property on Manager entity
New types
New queries
New mutations
Notes
from
orto
existsTODO: Expand this on the issue conversation with other relationship types procedurally when implementation gets completed.
Alternatives
No response
Contribution
Yes, I will work on a PR
Keywords
graphql, relationships, integration
The text was updated successfully, but these errors were encountered: