Discussion about missing field in query results for a document in a private GitHub repo
43 replies
Last updated: May 15, 2020
F
{ name: 'contacts', title: 'Contacts', type: 'array', of: [ { type: 'contact_person' } ] }
May 15, 2020, 9:37 AM
K
if contact_person is a document you need:
... type: "array", of: [{ type: "reference", to: { type: "contact_person" } }],
May 15, 2020, 9:40 AM
F
It’s not, it’s just embedded in the document
May 15, 2020, 9:41 AM
F
Do I have to make contact_person in to a document?
May 15, 2020, 9:41 AM
F
At least everything works in the studio, but my query doesn’t return the contacts field as part of the main document.
May 15, 2020, 9:41 AM
K
what is a contact_person? 🙂
May 15, 2020, 9:41 AM
F
Object
May 15, 2020, 9:41 AM
F
export default { name: 'contact_person', type: 'object', title: 'Contact person', fields: [ { name: 'name', title: 'Name', type: 'string' }, { name: 'email', title: 'Email', type: 'string' }, { name: 'field', title: 'Field of expertise', type: 'string' } ] };
May 15, 2020, 9:42 AM
K
how does your query look?
May 15, 2020, 9:42 AM
F
export async function preload({ params, query }) { const noticeQuery = `*[_type == "notice"][0]`; const noticeProjection = `{ ..., body[]{ ..., children[]{ ..., "asset": asset-> } } }`; const notice = await client.fetch(noticeQuery + noticeProjection);
May 15, 2020, 9:42 AM
K
did you deploy to sanity after you created the object?
May 15, 2020, 9:44 AM
K
sanity deploy
May 15, 2020, 9:44 AM
F
I’m running the studio locally (and deployed)
May 15, 2020, 9:44 AM
F
deployed to Netlify. I’ll try to deploy again.
May 15, 2020, 9:44 AM
M
Is the field not returned on the front-end side or not even in the playground after running
sanity graphql deploy?
May 15, 2020, 9:47 AM
F
I’ve never run
sanity graphql deploy, I’m deploying our studio only to Netlify and running it locally.
May 15, 2020, 9:47 AM
M
Can you see the values if you inspect your document within the Studio?
May 15, 2020, 9:47 AM
F
I could, but for some reason the schema didn’t update after deploying, so the studio offered me to unset the
contacts
May 15, 2020, 9:48 AM
M
I see, so the deploy might not have happened successfully. Do you see any errors in your Netlify build log?
May 15, 2020, 9:49 AM
F
I’ll re-build and re-deploy. Locally running I can see the
contactsfield in the studio.
May 15, 2020, 9:49 AM
F
Re-deployed and now it’s there
May 15, 2020, 9:51 AM
F
However the query still return nothing!
May 15, 2020, 9:51 AM
F
const noticeQuery = `*[_type == "notice"][0]`; const noticeProjection = `{ contacts, ..., body[]{ ..., children[]{ ..., "asset": asset-> } } }`;
May 15, 2020, 9:51 AM
F
It is there when I inspect the data in studio. But not when I query the data.
May 15, 2020, 9:53 AM
M
What happens if you try without
contactsand leave
...,intact?
May 15, 2020, 9:54 AM
M
Also, are you sure it is there on the specific single
noticedocument you are querying with
[0]?
May 15, 2020, 9:55 AM
P
What happens if you try without
contactsand leave
...,intact?
May 15, 2020, 9:54 AM
A
Still missing contacts. And there is only one document.
May 15, 2020, 9:55 AM
P
Also, are you sure it is there on the specific single
noticedocument you are querying with
[0]?
May 15, 2020, 9:55 AM
A
Re-deployed and now it’s there
May 15, 2020, 9:51 AM
A
However the query still return nothing!
May 15, 2020, 9:51 AM
A
const noticeQuery = `*[_type == "notice"][0]`; const noticeProjection = `{ contacts, ..., body[]{ ..., children[]{ ..., "asset": asset-> } } }`;
May 15, 2020, 9:51 AM
P
If you have the Vision plugin installed in your Studio, are you able to get the data there with the same query?
May 15, 2020, 9:58 AM
P
If you have the Vision plugin installed in your Studio, are you able to get the data there with the same query?
May 15, 2020, 9:58 AM
P
If you have the Vision plugin installed in your Studio, are you able to get the data there with the same query?
May 15, 2020, 9:58 AM
A
No, it’s not there with Vision
May 15, 2020, 9:59 AM
A
Only when I inspect the document
May 15, 2020, 9:59 AM
A
It is there when I inspect the data in studio. But not when I query the data.
May 15, 2020, 9:53 AM
P
That’s strange. Is the document published?
May 15, 2020, 10:04 AM
A
Yes
May 15, 2020, 10:04 AM
P
Do you have any repo you could share? (in DM if you prefer) - or a zip of the schema files.
May 15, 2020, 10:04 AM
A
Wait a sec.
May 15, 2020, 10:04 AM
A
It’s a private github repo. Who can I add to it?
May 15, 2020, 10:05 AM
P
(Resolved in DM)
May 15, 2020, 4:39 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.