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

  • WPGraphQL\AppContext
  • WPGraphQL\Data\Config
  • WPGraphQL\Data\ConnectionResolver
  • WPGraphQL\Data\DataSource
  • WPGraphQL\Data\Loader
  • WPGraphQL\Router
  • WPGraphQL\Type\Avatar\AvatarType
  • WPGraphQL\Type\Comment\CommentQuery
  • WPGraphQL\Type\Comment\CommentType
  • WPGraphQL\Type\Comment\Connection\CommentConnectionArgs
  • WPGraphQL\Type\Comment\Connection\CommentConnectionDefinition
  • WPGraphQL\Type\Comment\Connection\CommentConnectionResolver
  • WPGraphQL\Type\CommentAuthor\CommentAuthorQuery
  • WPGraphQL\Type\CommentAuthor\CommentAuthorType
  • WPGraphQL\Type\EditLock\EditLockType
  • WPGraphQL\Type\Enum\MediaItemStatusEnumType
  • WPGraphQL\Type\Enum\MimeTypeEnumType
  • WPGraphQL\Type\Enum\PostObjectFieldFormatEnumType
  • WPGraphQL\Type\Enum\PostStatusEnumType
  • WPGraphQL\Type\Enum\PostTypeEnumType
  • WPGraphQL\Type\Enum\RelationEnumType
  • WPGraphQL\Type\Enum\TaxonomyEnumType
  • WPGraphQL\Type\MediaItem\MediaItemType
  • WPGraphQL\Type\MediaItem\Mutation\MediaItemCreate
  • WPGraphQL\Type\MediaItem\Mutation\MediaItemDelete
  • WPGraphQL\Type\MediaItem\Mutation\MediaItemMutation
  • WPGraphQL\Type\MediaItem\Mutation\MediaItemUpdate
  • WPGraphQL\Type\Plugin\Connection\PluginConnectionDefinition
  • WPGraphQL\Type\Plugin\Connection\PluginConnectionResolver
  • WPGraphQL\Type\Plugin\PluginQuery
  • WPGraphQL\Type\Plugin\PluginType
  • WPGraphQL\Type\PostObject\Connection\PostObjectConnectionArgs
  • WPGraphQL\Type\PostObject\Connection\PostObjectConnectionArgsDateQuery
  • WPGraphQL\Type\PostObject\Connection\PostObjectConnectionDefinition
  • WPGraphQL\Type\PostObject\Connection\PostObjectConnectionResolver
  • WPGraphQL\Type\PostObject\Mutation\PostObjectCreate
  • WPGraphQL\Type\PostObject\Mutation\PostObjectDelete
  • WPGraphQL\Type\PostObject\Mutation\PostObjectMutation
  • WPGraphQL\Type\PostObject\Mutation\PostObjectUpdate
  • WPGraphQL\Type\PostObject\Mutation\TermObjectDelete
  • WPGraphQL\Type\PostObject\PostObjectQuery
  • WPGraphQL\Type\PostObject\PostObjectType
  • WPGraphQL\Type\PostType\PostTypeType
  • WPGraphQL\Type\RootMutationType
  • WPGraphQL\Type\RootQueryType
  • WPGraphQL\Type\Setting\SettingQuery
  • WPGraphQL\Type\Setting\SettingType
  • WPGraphQL\Type\Taxonomy\TaxonomyType
  • WPGraphQL\Type\TermObject\Connection\TermObjectConnectionArgs
  • WPGraphQL\Type\TermObject\Connection\TermObjectConnectionDefinition
  • WPGraphQL\Type\TermObject\Connection\TermObjectConnectionResolver
  • WPGraphQL\Type\TermObject\Mutation\TermObjectCreate
  • WPGraphQL\Type\TermObject\Mutation\TermObjectMutation
  • WPGraphQL\Type\TermObject\Mutation\TermObjectUpdate
  • WPGraphQL\Type\TermObject\TermObjectQuery
  • WPGraphQL\Type\TermObject\TermObjectType
  • WPGraphQL\Type\Theme\Connection\ThemeConnectionDefinition
  • WPGraphQL\Type\Theme\Connection\ThemeConnectionResolver
  • WPGraphQL\Type\Theme\ThemeType
  • WPGraphQL\Type\Union\CommentAuthorUnionType
  • WPGraphQL\Type\Union\PostObjectUnionType
  • WPGraphQL\Type\Union\TermObjectUnionType
  • WPGraphQL\Type\User\Connection\UserConnectionArgs
  • WPGraphQL\Type\User\Connection\UserConnectionDefinition
  • WPGraphQL\Type\User\Connection\UserConnectionResolver
  • WPGraphQL\Type\User\Mutation\UserCreate
  • WPGraphQL\Type\User\Mutation\UserDelete
  • WPGraphQL\Type\User\Mutation\UserMutation
  • WPGraphQL\Type\User\Mutation\UserUpdate
  • WPGraphQL\Type\User\UserQuery
  • WPGraphQL\Type\User\UserType
  • WPGraphQL\Type\WPEnumType
  • WPGraphQL\Type\WPInputObjectType
  • WPGraphQL\Type\WPObjectType
  • WPGraphQL\Types
  • WPGraphQL\Utils\InstrumentSchema
  • WPGraphQL\WPSchema

Interfaces

  • WPGraphQL\Data\ConnectionResolverInterface
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 
<?php
namespace WPGraphQL\Type\PostObject\Connection;

use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\InputObjectType;
use WPGraphQL\Type\WPEnumType;
use WPGraphQL\Type\WPInputObjectType;
use WPGraphQL\Types;

/**
 * Class PostObjectConnectionArgs
 *
 * This sets up the Query Args for post_object connections, which uses WP_Query, so this defines the allowed
 * input fields that will be passed to the WP_Query
 *
 * @package WPGraphQL\Type
 * @since   0.0.5
 */
class PostObjectConnectionArgs extends WPInputObjectType {

    /**
     * Stores the date query object
     *
     * @var PostObjectConnectionArgsDateQuery obj $date_query
     * @since  0.5.0
     * @access private
     */
    private static $date_query;

    /**
     * This holds the field definitions
     *
     * @var array $fields
     * @since 0.0.5
     */
    public static $fields;

    /**
     * This holds the orderby_field input object type
     *
     * @var array $orderby_field
     */
    private static $orderby_field;

    /**
     * This holds the orderby EnumType definition
     *
     * @var EnumType
     */
    private static $orderby_enum;

    /**
     * PostObjectConnectionArgs constructor.
     *
     * @since 0.0.5
     */
    public function __construct( $config = [] ) {
        $config['name'] = 'QueryArgs';
        $config['fields'] = self::fields();
        parent::__construct( $config );
    }

    /**
     * fields
     *
     * This defines the fields that make up the PostObjectConnectionArgs
     *
     * @return array
     * @since 0.0.5
     */
    private static function fields() {

        if ( null === self::$fields ) :
            $fields = [

                /**
                 * Author $args
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
                 * @since 0.0.5
                 */
                'author'       => [
                    'type'        => Types::int(),
                    'description' => __( 'The user that\'s connected as the author of the object. Use the 
                            userId for the author object.', 'wp-graphql' ),
                ],
                'authorName'   => [
                    'type'        => Types::string(),
                    'description' => __( 'Find objects connected to the author by the author\'s "nicename"', 'wp-graphql' ),
                ],
                'authorIn'     => [
                    'type'        => Types::list_of( Types::id() ),
                    'description' => __( 'Find objects connected to author(s) in the array of author\'s userIds', 'wp-graphql' ),
                ],
                'authorNotIn'  => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Find objects NOT connected to author(s) in the array of author\'s 
                            userIds', 'wp-graphql' ),
                ],

                /**
                 * Category $args
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
                 * @since 0.0.5
                 */
                'categoryId'   => [
                    'type'        => Types::int(),
                    'description' => __( 'Category ID', 'wp-graphql' ),
                ],
                'categoryName' => [
                    'type'        => Types::string(),
                    'description' => __( 'Use Category Slug', 'wp-graphql' ),
                ],
                'categoryIn'   => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Array of category IDs, used to display objects from one 
                                        category OR another', 'wp-graphql' ),
                ],

                /**
                 * Tag $args
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
                 * @since 0.0.5
                 */
                'tag'          => [
                    'type'        => Types::string(),
                    'description' => __( 'Tag Slug', 'wp-graphql' ),
                ],
                'tagId'        => [
                    'type'        => Types::string(),
                    'description' => __( 'Use Tag ID', 'wp-graphql' ),
                ],
                'tagIn'        => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Array of tag IDs, used to display objects from one tag OR 
                            another', 'wp-graphql' ),
                ],
                'tagSlugAnd'   => [
                    'type'        => Types::list_of( Types::string() ),
                    'description' => __( 'Array of tag slugs, used to display objects from one tag OR 
                            another', 'wp-graphql' ),
                ],
                'tagSlugIn'    => [
                    'type'        => Types::list_of( Types::string() ),
                    'description' => __( 'Array of tag slugs, used to exclude objects in specified 
                            tags', 'wp-graphql' ),
                ],

                /**
                 * Search Parameter
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter
                 * @since 0.0.5
                 */
                'search'       => [
                    'name'        => 'search',
                    'type'        => Types::string(),
                    'description' => __( 'Show Posts based on a keyword search', 'wp-graphql' ),
                ],

                /**
                 * Post & Page Parameters
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
                 * @since 0.0.5
                 */
                'id'           => [
                    'type'        => Types::int(),
                    'description' => __( 'Specific ID of the object', 'wp-graphql' ),
                ],
                'name'         => [
                    'type'        => Types::string(),
                    'description' => __( 'Slug / post_name of the object', 'wp-graphql' ),
                ],
                'title'        => [
                    'type'        => Types::string(),
                    'description' => __( 'Title of the object', 'wp-graphql' ),
                ],
                'parent'       => [
                    'type'        => Types::string(),
                    'description' => __( 'Use ID to return only children. Use 0 to return only top-level 
                            items', 'wp-graphql' ),
                ],
                'parentIn'     => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Specify objects whose parent is in an array', 'wp-graphql' ),
                ],
                'parentNotIn'  => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Specify posts whose parent is not in an array', 'wp-graphql' ),
                ],
                'in'           => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Array of IDs for the objects to retrieve', 'wp-graphql' ),
                ],
                'notIn'        => [
                    'type'        => Types::list_of( Types::int() ),
                    'description' => __( 'Specify IDs NOT to retrieve. If this is used in the same query as "in", 
                            it will be ignored', 'wp-graphql' ),
                ],
                'nameIn'       => [
                    'type'        => Types::list_of( Types::string() ),
                    'description' => __( 'Specify objects to retrieve. Use slugs', 'wp-graphql' ),
                ],

                /**
                 * Password parameters
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Password_Parameters
                 * @since 0.0.2
                 */
                'hasPassword'  => [
                    'type'        => Types::string(),
                    'description' => __( 'True for objects with passwords; False for objects without passwords; 
                            null for all objects with or without passwords', 'wp-graphql' ),
                ],
                'password'     => [
                    'type'        => Types::string(),
                    'description' => __( 'Show posts with a specific password.', 'wp-graphql' ),
                ],

                /**
                 * post_type
                 * NOTE: post_type is intentionally not supported as it's the post_type is the entity entry
                 * point for the queries
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
                 * @since 0.0.2
                 */

                /**
                 * Status parameters
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters
                 * @since 0.0.2
                 */
                'status'       => [
                    'type' => Types::post_status_enum(),
                ],

                /**
                 * Order & Orderby parameters
                 *
                 * @see   : https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
                 * @since 0.0.2
                 */
                'orderby'      => [
                    'type'        => Types::list_of( self::orderby_field() ),
                    'description' => __( 'What paramater to use to order the objects by.', 'wp-graphql' ),
                ],
                'dateQuery'    => self::date_query(),
                'mimeType'     => [
                    'type'        => Types::mime_type_enum(),
                    'description' => __( 'Get objects with a specific mimeType property', 'wp-graphql' ),
                ],
            ];

            self::$fields = self::prepare_fields( $fields, 'QueryArgs' );
        endif;
        return self::$fields;

    }

    /**
     * This returns the definition for the PostObjectConnectionArgsDateQuery
     *
     * @return PostObjectConnectionArgsDateQuery object
     * @since  0.0.5
     * @access public
     */
    public static function date_query() {
        return self::$date_query ? : ( self::$date_query = new PostObjectConnectionArgsDateQuery() );
    }

    /**
     * This returns the orderby field which accepts a field (enum) and an order (enum, ASC/DESC)
     *
     * @return InputObjectType object
     * @access private
     */
    private static function orderby_field() {
        if ( null === self::$orderby_field ) {

            self::$orderby_field = new WPInputObjectType( [
                'name' => 'OrderByOptions',
                'fields' => self::prepare_fields( [
                    'field' => Types::non_null( self::orderby_enum() ),
                    'order' => new WPEnumType( [
                        'name'   => 'Order',
                        'values' => [
                            'ASC'  => [ 'value' => 'ASC' ],
                            'DESC' => [ 'value' => 'DESC' ],
                        ],
                    ] ),
                ], 'OrderByOptions' ),
            ] );
        }

        return ! empty( self::$orderby_field ) ? self::$orderby_field : null;
    }

    /**
     * orderby_enum
     * This returns the orderby enum type for the PostObjectQueryArgs
     *
     * @return EnumType
     * @since 0.0.5
     */
    private static function orderby_enum() {

        if ( null === self::$orderby_enum ) :
            self::$orderby_enum = new WPEnumType([
                'name' => 'OrderBy',
                'values' => [
                    'AUTHOR' => [
                        'value'       => 'post_author',
                        'description' => __( 'Order by author', 'wp-graphql' ),
                    ],
                    'TITLE' => [
                        'value'       => 'post_title',
                        'description' => __( 'Order by title', 'wp-graphql' ),
                    ],
                    'SLUG' => [
                        'value'       => 'post_name',
                        'description' => __( 'Order by slug', 'wp-graphql' ),
                    ],
                    'MODIFIED' => [
                        'value'       => 'post_modified',
                        'description' => __( 'Order by last modified date', 'wp-graphql' ),
                    ],
                    'DATE' => [
                        'value'       => 'post_date',
                        'description' => __( 'Order by publish date', 'wp-graphql' ),
                    ],
                    'PARENT' => [
                        'value'       => 'post_parent',
                        'description' => __( 'Order by parent ID', 'wp-graphql' ),
                    ],
                    'IN' => [
                        'value'       => 'post__in',
                        'description' => __( 'Preserve the ID order given in the IN array', 'wp-graphql' ),
                    ],
                    'NAME_IN' => [
                        'value'       => 'post_name__in',
                        'description' => __( 'Preserve slug order given in the NAME_IN array', 'wp-graphql' ),
                    ],
                ],
            ]);
        endif;
        return self::$orderby_enum;
    }

}
API documentation generated by ApiGen