https://github.com/zaibot/graphql-cosmos
GraphQL to Cosmos directives
https://github.com/zaibot/graphql-cosmos
Last synced: 3 months ago
JSON representation
GraphQL to Cosmos directives
- Host: GitHub
- URL: https://github.com/zaibot/graphql-cosmos
- Owner: Zaibot
- Created: 2020-05-03T15:35:14.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T13:55:37.000Z (about 2 years ago)
- Last Synced: 2025-02-11T14:07:33.235Z (4 months ago)
- Language: TypeScript
- Size: 1.99 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
graphql-cosmos
# Concept
@cosmos(container, ours, theirs)
The `container` argument indicates the value of the field is stored in a different Cosmos Container
The `ours` argument tells the resolver that this entity owns the information and specifies what underlying column to use. Combined with `container` this indicates the relational ID column.
The `theirs` argument tells the resolver that the relational information is owned by an entity in the `container` Cosmos Container.
Pseudo code:
```
Person {
id
name
preferredContactId?
}Contact {
id
personId
phonenumber
}
``````graphql
type Query {
people: [Person!]! @cosmos(container: "Persons")
}type Person {
id: ID
name: String!
contacts: [Contact!]! @cosmos(container: "Contacts", theirs: "personId")
perferredContact: Contact @cosmos(container: "Contacts", ours: "preferredContactId")
}type Contact {
person: Person! @cosmos(container: "Persons", ours: "personId")
preferredBy: [Person!]! @cosmos(container: "Persons", theirs: "preferredContactId")
phonenumber: String!
}
```