Skip to content

Post Format archives don't resolve with nodeByUri query #2190

@jasonbahl

Description

@jasonbahl

After enabling post formats using the snippet below:

add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );

And creating a post assigned to the video format, like so:

Screen Shot 2021-12-21 at 2 05 41 PM

I can visit the url /type/video and get an archive of posts of said post-format.

Screen Shot 2021-12-21 at 2 03 42 PM

We can see in the "body class" that WordPress is resolving this to the archive of the post format.

However, if we take the uri and use it in a nodeByUri query, we get a null response.

query:

query GetNodeByUri($uri: String!) {
  node: nodeByUri(uri: $uri) {
    ...NodeByUri
  }
}

fragment NodeByUri on UniformResourceIdentifiable {
  __typename
  uri
  id
  ...DatabaseIdentifier
  ...ContentType
  ...User
  ...TermNode
  ...ContentNode
  ...MediaItem
}

fragment DatabaseIdentifier on DatabaseIdentifier {
  databaseId
}

fragment MediaItem on MediaItem {
  id
  mimeType
}

fragment ContentType on ContentType {
  name
  isFrontPage
  isPostsPage
}

fragment TermNode on TermNode {
  isTermNode
  slug
  taxonomyName
}

fragment ContentNode on ContentNode {
  isContentNode
  slug
  contentType {
    node {
      name
    }
  }
  template {
    templateName
  }
}

fragment User on User {
  nicename
  databaseId
}

variables:

{
  "uri": "/type/video"
}

Result

The result is null. WPGraphQL doesn't properly return the PostFormat node as expected.

Screen Shot 2021-12-21 at 2 03 22 PM

Expectation

I expect to get a node of the PostFormat type in response to the query.

Similar to if I queried a category by URI, like so:

Screen Shot 2021-12-21 at 2 11 21 PM


Additional Info:

WPGraphQL does properly expose the PostFormat type to the Schema. We can query like so:

{
  posts {
    nodes {
      id
      title
      postFormats {
        nodes {
          id
          name
          uri
        }
      }
    }
  }
}

And get a response like so:

Screen Shot 2021-12-21 at 2 12 55 PM

So it doesn't appear to be an issue with Post Formats not being supported by WPGraphQL, just seems like a nodeByUri resolver issue.

Metadata

Metadata

Assignees

Labels

component: queryRelating to GraphQL Queriesimpact: medMinor performance improvements, fix broad user base issuesnot staleShort-circuits stalebot. USE SPARINGLYobject type: termRelating to the Term Typestype: 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