graphql-community / graphql-community/graphql-directive-uid
Question: Ability to retrieve a UID in a mutation resolver
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 23
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to use the uid as a key to mutate data in my resolver, since the uid only lives in the directive and is output via a graphql query i'm having a hard time designing the best way to link the uid back to the data outside of the graph. ie.
const schema = gql`
directive @uid(from: [String]) on OBJECT
type Element @uid(from: ["email", "name"]) {
name: String!
email: String!
}
type Query {
elements: [Element]
}
mutation DeleteElement($uid:String) {
deleteElement(uid:$uid) : Boolean
}`;
const elements = [{name:"bill", email: "blah@blah.com"}]
const resolvers = {
Query: {
elements: () => elements
},
Mutations: {
deleteElement: (parent, {uid}) => {
// how am I supposed to find the index in elements without redoing the hash work you do in the resolve function of UniqueIdDirective
}
}
}
I understand I could redo the work that is done here UniqueId.visitObject()fields[].resolve
but this seems like a hack.
Should this uid be used for anything but caching? Is there another way to resolve the uid outside of the graph? Has anyone done something else to resolve this problem?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading UniqueId.visitObject() and its fields[].resolve implementation, then trace how the generated UID is exposed in GraphQL responses. Determine whether the project should support retrieving that UID in mutation resolvers or document that it is only for caching; the issue is done when the intended resolver-facing behavior is defined and supported or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100