Overview
  • Namespace
  • Class

Namespaces

  • WPGraphQL
    • Data
    • Type
      • Avatar
      • Comment
        • Connection
      • CommentAuthor
      • EditLock
      • Enum
      • MediaItem
        • Mutation
      • Plugin
        • Connection
      • PostObject
        • Connection
        • Mutation
      • PostType
      • Setting
      • Taxonomy
      • TermObject
        • Connection
        • Mutation
      • Theme
        • Connection
      • Union
      • User
        • Connection
        • Mutation
    • Utils

Classes

  • CommentAuthorUnionType
  • PostObjectUnionType
  • TermObjectUnionType

Class PostObjectUnionType

Class PostObjectUnionType

In WordPress, relations can be set to a post object by ID, but in many cases there's no strict control over what post_type the related post can be, so in many cases it's unknown what "post_type" the related post is until the post has been queried and returned. Some examples of such relations are:

  • Posts can have a parent_id set, and the parent_id can be of any post_type, so it's unknown what type of postObject will be returned until the query has been run.

  • Attachments (mediaItems) can be uploaded to any post_type as well, so their "uploadedTo" property can return any type of post object.

GraphQL\Type\Definition\UnionType
Extended by WPGraphQL\Type\Union\PostObjectUnionType
Namespace: WPGraphQL\Type\Union
Package: WPGraphQL\Type\Union
Since: 0.0.6
Located at Type/Union/PostObjectUnionType.php

Methods summary

public
# __construct( )

PostObjectUnionType constructor.

PostObjectUnionType constructor.

Since

0.0.6
public array|null
# getPossibleTypes( )

This defines the possible types that can be resolved by this union

This defines the possible types that can be resolved by this union

Returns

array|null
An array of possible types that can be resolved by the union

Since

0.0.5
API documentation generated by ApiGen