treefarmstudio / astro-sanity-minimal-starter

https://astro-sanity-minimal-starter.netlify.app/
MIT License
105 stars 14 forks source link

Main branch: Author not displaying on single post #6

Closed djmtype closed 2 years ago

djmtype commented 2 years ago

For some odd reason, the author isn't showing up on the single post. BTW, authors are published with title, slug and bio.

The GraphQL schema appears right:

{
  Post(id: "5ee8b95f-f2b9-4e9d-b2b3-0b7930cbac5a") {
    title
    author {
      name
    }
  }
}

JSON returned:

{
  "data": {
    "Post": {
      "title": "My Second Post",
      "author": {
        "name": "George Michael"
      }
    }
  }
}

All other fields are displaying just fine.

Using Astro 0.22.1 and Sanity CLI 2.26.0

djmtype commented 2 years ago

@jaydanurwin Looking at lib/api.js, it looks like you're converting this over from GraphQL to GROQ?

Looking further at your video, https://youtu.be/-jAWLTfsSQw?t=424, it appears that way.

Thanks for tutorial and saving the GraphQL version as a separate branch!

jaydanurwin commented 2 years ago

Closing this as the main branch has moved over to GROQ, GRAPHQL branch will stick around for those who still want to use it