Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Querying data based on relation #210

Open
sn3h opened this issue May 16, 2020 · 2 comments
Open

Querying data based on relation #210

sn3h opened this issue May 16, 2020 · 2 comments

Comments

@sn3h
Copy link

sn3h commented May 16, 2020

Hi, I am kinda new to this stuff and after few hours I still have no idea how to solve (to me) a simple problem using this plugin.
Let's have a Tag and Article custom types. Article has group fields of relationship fied limited to Tags.
Let's have 4 articles with these tags:
A1[T1,T2,T3], A2[T1], A3[T2], A4[T3]

GraphQL offers me allArticles, allTags, article and tag. But I see no way how I could ask for something like this:
allArticles ( filter: {article_tags: "T1", limit: 3})

Not sure if I am writing that right, but the point is to get max. 3 newest articles that has T1. So I could therefore link next article from articles, next article with some tag, or newest articles from each tag..

Ability to that easily has huge implications for me. Thanks to anyone who can help :)

@dmtrek14
Copy link

Prismic doesn't allow you to query linked items that are in a group or slice. I asked that same question recently in the Community Forum.

My case is that I had custom types of Publication and Subject and I wanted to filter Publications by Subject, so that I could have a page for each subject. What I ended up doing was, in the gatsby-node, iterating through all of the Publications and adding them to an array. I used the createPage function to create a page for each Subject and passed a filtered version of my Publications array in the context.

So, the issue is not with this plugin, but Prismic's own limitations. I did use this plugin to create individual pages for each Publication, but I had to create my AllPublications page in the gatsby-node and pass in my array.

Let me know if you want me to pass on any code samples for what I did.

@sn3h
Copy link
Author

sn3h commented May 20, 2020

I solved it with gatsby-source-prismic, which has no problem with that.. I can't create custom fields on nodes there, but that's another story... Context is fine, but I'd like to have access to things even outside of context :/
Anyway, thank you for your time, much appreciated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants