Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACF Relationship fields with private or draft post selected results in error in query #11

Open
mdrayer opened this issue Feb 27, 2020 · 3 comments

Comments

@mdrayer
Copy link

mdrayer commented Feb 27, 2020

When I attempt to query the ID of a post in a relationship field as an anonymous user and the post is set to some non-public availability (i.e. private or draft), the query yields an error. I would expect the query would just give null in place of the given Post with no error.

To replicate, set up a Gutenberg block and an ACF Field Group for said block. Add a relationship field to the block. On a post, add the block to its content and select a private or draft post in the relationship field. Now do a GraphQL query on the post as an anonymous user. You will get an error.

Example query (where AcfRelatedContentBlock is my custom Gutenberg block and content_select is the Relationship field):

{
  page(id: "some-test-page", idType: URI) {
    blocks {
      __typename
      ... on AcfRelatedContentBlock {
        acf {
          content_select {
            __typename
            ... on Post {
              id
            }
          }
        }
      }
    }
  }
}

Example result:

{
  "errors": [
    {
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 10,
          "column": 15
        }
      ],
      "path": [
        "page",
        "blocks",
        0,
        "acf",
        "content_select",
        0,
        "id"
      ]
    }
  ],
  "data": {
    "page": {
      "blocks": [
        {
          "__typename": "AcfRelatedContentBlock",
          "acf": {
            "content_select": [
              null
            ]
          }
        }
      ]
    }
  }
}

Note that this happens for uri as well.

@mdrayer
Copy link
Author

mdrayer commented Feb 27, 2020

This might be a result of a similar issue in WP GraphQL ACF plugin: wp-graphql/wp-graphql-acf#85.

@pristas-peter
Copy link
Owner

Thank you for posting the issue, i will try to have a look at it, probably next week though.

@patibugaj
Copy link

I have the same issue. Any working solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants