adrianhajdin / project_graphql_blog

With featured and recent posts, categories. full markdown articles, author information, comments, and much more, this fully responsive CMS Blog App is the best Blog Application that you can currently find on YouTube. And what's best of all is that you and your clients can manage the blog from a dedicated Content Management System.
https://jsmastery.pro
1.47k stars 348 forks source link

Slug must be defined #35

Open Luth-Badila opened 2 years ago

Luth-Badila commented 2 years ago

'slug' must be defined, why is this still happening even though i have added is empty from lodash ? Screenshot_4 Screenshot_5 Screenshot_6

Hoxtygen commented 2 years ago

'slug' must be defined, why is this still happening even though i have added is empty from lodash ? Screenshot_4 Screenshot_5 Screenshot_6

Did you solve this? Making another API call in the Comments component is unneccessay. while fetching postDetails you can include the comments and pass it to the Comments component as prop..

Make the postDetails query like this

query GetPostDetails($slug: String!) {
    post(where: {slug: $slug}) {
            id
        author {
          bio
          name
          photo {
            url
          }
          id
        }
        createdAt
        slug
        title
        excerpt
        featuredImage {
          url
        }
        categories {
          name
          slug
        }
        content {
          raw
        }
        comments {
          id
          name
          email
          comment
        }

    }
    }
    `
olamission commented 1 year ago

How I got rid of this error is by changing the getPostdetails on slug.js from (params) to ({params}). before image after image

but now i get this error image

but now i think that easier to solve , ill give you un update after I solved this one

olamission commented 1 year ago

To get rid of the other errors it was based on me not following the tutorial exactly and making basic mistakes before - getSimilarPosts from sevices/index.js image After image Added slug and categories Before , more important in my opinion post/slug.js image After image These undefined issues seem to come from not putting the right parameters so it seems.