Skip to content

How to Add extra arguments into exsisting singular post type #2480

Discussion options

You must be logged in to vote

Hey ya'll

Currently this is a two-step process:

First, you need to filter the connection config to add the input args to the schema:

add_filter(
  'graphql_wp_connection_type_config',
  static function( array $config ): array {
    // Add an input arg only for RootQuery -> Posts.
    if ( 'RootQuery' !== $config['fromType'] || 'Post' !== $config['toType'] ) {
      return $config;
    }

    $config['connectionArgs'] = array_merge(
      $config['connectionArgs'],
      [ 
        'myCustomInput' => [
          'type' => 'String'
          'description' => 'What this does to the query',
        ],
        // other new input field configs
      ]
    );

    return $config;  
  },
  10
);

T…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@okansahin
Comment options

Answer selected by jasonbahl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Further information is requested Close Candidate Needs confirmation before closing has: solution A solution to this issue has been provided.
4 participants
Converted from issue

This discussion was converted from issue #2097 on August 17, 2022 21:12.