Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Add GraphQL support #31

Open
chrysos opened this issue Jan 17, 2023 · 1 comment
Open

Add GraphQL support #31

chrysos opened this issue Jan 17, 2023 · 1 comment

Comments

@chrysos
Copy link

chrysos commented Jan 17, 2023

Hello, your plugin is great, congratulations.

It would be really nice if you added support for WP-Graphql.

https://www.wpgraphql.com/

@samfrank
Copy link

samfrank commented Apr 9, 2024

Hey!

I have managed to add the Icon Picker to WPGraphQL. Hopefully this will help someone in the future.

I am using the ACF for WPGraphQl v2, the documentation for this will be here: https://acf.wpgraphql.com/

More specifically I used this example code found on these pages

https://acf.wpgraphql.com/adding-support-for-3rd-party-acf-field-type/
https://github.com/wp-graphql/wpgraphql-acf/tree/develop/src/ThirdParty/AcfExtended/FieldType

        // Add field-resolver
        add_action( 'wpgraphql/acf/registry_init', function() {
            register_graphql_acf_field_type('icon-picker');
        });

        register_graphql_acf_field_type(
            'icon-picker',
            [
                'graphql_type' => static function () {
                    return 'String';
                },
                'resolve' => static function ( $root, $args, $context, $info, $field_type, $field_config ) {
                    $value = $field_config->resolve_field( $root, $args, $context, $info );

                    if ( empty( $value ) ) {
                        return null;
                    }

                    return $value;
                },
            ]
        );

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants