Skip to content
New issue

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

belongsTo nodes + referenced document filter not returning data #2

Open
bokinga opened this issue Jan 31, 2020 · 7 comments
Open

belongsTo nodes + referenced document filter not returning data #2

bokinga opened this issue Jan 31, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@bokinga
Copy link

bokinga commented Jan 31, 2020

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.

  1. Author implements belongsTo (founded in schema and docs) but seems like no data is attached.

  2. 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.

Screen Shot 2020-01-31 at 11 55 55

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

@bokinga
Copy link
Author

bokinga commented Jan 31, 2020

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
Screen Shot 2020-01-31 at 13 30 09

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) }) })

@kmelve
Copy link
Member

kmelve commented Feb 1, 2020

Hi! We need to look into this – let us come back to you!

@kmelve kmelve added the bug Something isn't working label Feb 1, 2020
@ajrowland
Copy link

Great project. Any further thoughts on this issue?

@kmelve
Copy link
Member

kmelve commented Apr 27, 2020

Hi! We haven't gotten around to looking at this yet. We'll update this thread once we have.

@DenisValcke
Copy link

Having the same issue. Tried to follow the "Taxonomy pages" docs but I get no data.

@riledigital
Copy link

Curious about the status of this; I'm having the same issue as well.

@typeoneerror
Copy link

Looks like the issue persists. I've been reading numerous blogs that reference using belongsTo like this. Curious how it worked for these folks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants