gridsome-source-sanity
gridsome-source-sanity copied to clipboard
belongsTo nodes + referenced document filter not returning data
Hi,
After local install 'sanity-gridsome' example and starting dev environment I tried to test belongsTo and filter data for related node, in this case for Post and Author.
I attached graphql playground screenshoots with concrete example.
-
Author implements belongsTo (founded in schema and docs) but seems like no data is attached.
-
With Post I tried to use filter for related nodes (authors:author) also existing with docs and implemented but no data returned (when filter removed, 3rd example, all is fine and Authors are listed)
Please, am I doing something wrong? Thanks.
Environment: node -v v10.16.3
npm -v 6.13.1
gridsome -v @gridsome/cli v0.3.1
sanity -v @sanity/cli version 0.146.0
Hi, some additional info.
I added new field to sanity Post model, only referencing one Author:
{ name: 'author', title: 'Author', type: 'reference', to: [{ type: 'author' }] },
1. Again I have no referenced post on the author query using graphql
2. In gridsome.server.js tried to use standard @sanity/client fetch on author with post references and I got results:
Authors: sanity-gridsome-web: { _id: '1b1c7451-c976-48fd-b416-73bf5a356f10', sanity-gridsome-web: name: 'My Name', sanity-gridsome-web: posts: sanity-gridsome-web: [ { title: 'Picture Perfect Cropping with Hotspots and stuff' }, sanity-gridsome-web: { title: 'A CMS I Can use on My Phone. Finally!' }, sanity-gridsome-web: { title: 'Exploration powered by structured content' }, sanity-gridsome-web: { title: 'My First Introduction to Portable Text' }, sanity-gridsome-web: { title: 'My brand new blog powered by Sanity.io' } ] }`
Query:
const authorsQuery = '*[_type == "author"] {name, _id, "posts": *[_type == "post" && references(^._id)]{title}}' const authorsParams = {} client.fetch(authorsQuery, authorsParams).then(authors => { console.log('Authors:') authors.forEach(author => { console.log(author) }) })
Hi! We need to look into this – let us come back to you!
Great project. Any further thoughts on this issue?
Hi! We haven't gotten around to looking at this yet. We'll update this thread once we have.
Having the same issue. Tried to follow the "Taxonomy pages" docs but I get no data.
Curious about the status of this; I'm having the same issue as well.
Looks like the issue persists. I've been reading numerous blogs that reference using belongsTo
like this. Curious how it worked for these folks!