Skip to content

Receiving wrong contentType when idType is set to URI #1850

@JariSavolainen

Description

@JariSavolainen

I have registered a custom post type. So when I query a page that has same slug/uri as the custom post type, I receive the custom post type instead. I tested this with contentNode as well. I have WP GraphQL Version 1.3.5 installed (WP 5.7).

So this ...

query getPageByURI {
  page(id: "example", idType: URI) {
    pageId
    title
    contentType {
      node {
        label
      }
    }
  }
  contentNode(id: "example", idType: URI, contentType: PAGE) {
    contentType {
      node {
        label
      }
    }
    ... on Page {
      pageId
    }
    ... on CustomPostType {
      customposttypeId
    }
  }
}

... returns this ...

{
  "data": {
    "page": {
      "pageId": 12345,
      "title": "Example",
      "contentType": {
        "node": {
          "label": "CustomPostTypes"
        }
      }
    },
    "contentNode": {
      "contentType": {
        "node": {
          "label": "CustomPostTypes"
        }
      },
      "customposttypeId": 12345
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: reproductionThis issue needs to be reproduced independentlystale?May need to be revalidated due to prolonged inactivitytype: bugIssue that causes incorrect or unexpected behavior

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions