Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"rename_graphql_field()" implemented and tested. #1830

Merged

Conversation

kidunot89
Copy link
Member

@kidunot89 kidunot89 commented Mar 31, 2021

What does this implement/fix? Explain your changes.

  • rename_graphql_field( $type, $field_name, $new_field_name ) implemented.
    • Use to replace conflicting field name.
  • AccessFunctionTest updated to WPGraphQLTestCase

Any other comments?

This allows users to replace a field name on a Type.

For example, let's say we want to rename the root user field to wpUser.

We could do that like so:

add_action( 'graphql_register_types', function() { 
  rename_graphql_field( 'RootQuery', 'user', 'wpUser' );
} );

And now we can see the wpUser field in the Schema, instead of the user field.

rename_graphql_field

@kidunot89 kidunot89 force-pushed the feature/replace-graphql-field-name branch 2 times, most recently from 9aa7ca3 to 80e8348 Compare March 31, 2021 00:55
@coveralls
Copy link

coveralls commented Mar 31, 2021

Coverage Status

Coverage remained the same at 78.928% when pulling ef2a02c on kidunot89:feature/replace-graphql-field-name into 4c47420 on wp-graphql:develop.

@kidunot89 kidunot89 force-pushed the feature/replace-graphql-field-name branch from 80e8348 to 43c4670 Compare March 31, 2021 08:12
@jasonbahl jasonbahl changed the title "replace_graphql_field_name()" implemented and tested. "rename_graphql_field()" implemented and tested. Apr 1, 2021
@jasonbahl jasonbahl merged commit d85fd34 into wp-graphql:develop Apr 1, 2021
@jasonbahl jasonbahl mentioned this pull request Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants