3

When I try to get an excerpt from WPGraphQL plugin and pass excerpt(format: RAW) in the query, it's working fine in the WPGraphiQL window, but when I'm executing the same query in Vue Apollo it's always returning null.

Here is my code:

apollo: {
    posts: gql`
        query {
          posts {
            nodes {
              title
              uri
              date
              databaseId
              featuredImage {
                sourceUrl
              }
              excerpt(format: RAW)
            }
          }
        }
      `
  },

Am I guessing right that it has to deal with enum type on the server-side and the way it's passed in Apollo query string? Also when I pass only excerpt without argument it returns excerpt with HTML tags, so... what's wrong?

mihauke
  • 31
  • 3

2 Answers2

1

Use excerpt(format: FORMATTED)

and use in html like this:

dangerouslySetInnerHTML={{ __html: node.excerpt }}
1

You can only access content in the RAW format if your user is authenticated. This is why you can see the RAW content in the WPGraphiQL window, but not when you try to get this same data from your Vue app. You need to authenticate the query in your app. https://www.wpgraphql.com/docs/authentication-and-authorization/

JVT
  • 54
  • 5