We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Many nodes are uniquely identifiable by more than one key. Common example: BlogPost.id and BlogPost.slug.
BlogPost.id
BlogPost.slug
First idea:
const BlogPostNode = node({ keys: ['id', 'slug'], // Array // keys arg is an array of { id?: string, slug?: string } // if possible, even better if it's a union { id: string } | { slug: string } load: async (keys) => { return keys.map(({ id, slug }) => id ? getById(id) : getBySlug(slug) ) } }) addNodeFields(User, (t) => ({ highlightedBlogPost: t.field({ type: BlogPostNode, // Can return either { id: string } | { slug: string } resolve: (parent) => ({ slug: parent.highlightedBlogPostSlug }) )} }))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Summary
Many nodes are uniquely identifiable by more than one key. Common example:
BlogPost.id
andBlogPost.slug
.Proposed Solution
First idea:
The text was updated successfully, but these errors were encountered: