0

I am using Gatsby with WordPress, and the native page permalinks/slugs are not carrying over to graphql properly after modifying them. (ie. old one are still cached)

I have this query that where I need to access not the outer slug but "slug inside of acf". How do I do this in graphql?

Here is my example query:

query getPage($slug: String!) {
  wordpressPage(slug : {eq: $slug}) {
    slug
    acf {
      title
      slug
      floorsizeunit
}

the outer nested slug is the old "bad value slug" I am currently filtering for but the slug I need to use inside wordPressPage is "acf.slug" or the slug inside acf. How can I access this value with graphql

Theorder
  • 669
  • 2
  • 9
  • 19
  • Are you talking about getting this value in your Gatsby pages? Why doesn't `acf.slug` work? Can you share your React code as well? (in general, you can run your query in GraphiQL to see what the response's shape looks like) – Robin Métral Apr 25 '20 at 12:37
  • [disable cache?] ... use different slug inside `createPage()` – xadm Apr 25 '20 at 15:22
  • Yes I am running inside graphql and for example wordpressPage(acf.slug : {eq: $slug}) won't work because of incorrect syntax. I figured out a better solution using the id , that way if the slug changes there is no unexpected behaviour git repo is here https://github.com/arhoy/realty-wordpress-client-template/blob/master/src/templates/PropertyPage.js – Theorder Apr 25 '20 at 19:41
  • @xadm Yes, I have tried to clear cache and wordpress permalinks and all. Not sure what the issues is with it not carrying over. Inside create page I am using the acf slug. The issue is getting the acf slug in the query above. For example: https://github.com/arhoy/realty-wordpress-client-template/blob/master/gatsby-node.js Either way using the wordpress generated id is the best solution in this case, but I still wont like to understand how I can filter down to access to acf fields on wordpressPage(slug : {eq: $slug}) if needed – Theorder Apr 25 '20 at 19:48
  • 1
    you're probably looking for https://github.com/gatsbyjs/gatsby/issues/3401#issuecomment-448036936 .... or use unique names (`acf_slug`) .... and page query is for something different than queries used creating pages ... doesn't need such functionality – xadm Apr 25 '20 at 21:43
  • elemMatch and filter yes that should work, thanks! – Theorder Apr 25 '20 at 22:11

0 Answers0