Skip to content

URI Query - Receiving Post for Incorrect Slug Path #3240

@Messa1

Description

@Messa1

Description

Is there a way to query by URI?
I have attempted this, but I encountered an issue in my React frontend. When I use $slug with /test/, I receive the post as expected. The same happens when I use /news/test/.
However, I only want to receive the post for /news/test/.

Steps to reproduce

  1. Set backend permalink to /news/%postname%/
  2. Try query
query GetPage($slug: String!) {
  nodeByUri(uri: $slug) {
    __typename
    ... on Page {
      id
      title
      slug
    }
    ... on Post {
      id
      title
      slug
    }
    uri
  }
}

First

{
  "slug": "test"
}

Second

{
  "slug": "/news/test"
}

Additional context

grafik
grafik
grafik

WPGraphQL Version

4.3.1

WordPress Version

6.6.2.

PHP Version

8.2.x

Additional environment details

Im at the moment testing it local.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

component: queryRelating to GraphQL Queriesobject type: postRelating to the Post Object Typestype: bugIssue that causes incorrect or unexpected behavior

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions