• Resolved Shashank Shekhar

    (@shashankitsoft)


    I have latest wordpress 6.5 (with woocommerce) and WPGraphQL 1.23 installed (also WooGraphQL 0.19.0). I wanted to use WP+Woo as graphql headless backend for the frontend application I am building in NextJs 14, for which the PODS Plugin looked very promising, as it says it has built-in graphql integration.

    I installed Pods – Custom Content Types and Fields plugin latest version 3.2.1 , and created a Settings Page with some text fields for global values like social media urls, etc.

    But I am unable to see any of these fields or groups from settings page in GraphiQL IDE.

    I created a content type with Pods for test, there I see the graphql tab to enable/disable. But no such setting to check wpgraphql available for the Settings Page I created.

    By what graphql query I can fetch those values? Or any code snippet need to write for it? The purpose for which I used Pods seems not working. Please suggest.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Paul Clark

    (@pdclark)

    See supported data types at https://docs.pods.io/code/wpgraphql-integration/

    Settings pages are not supported.

    See WPGraphQL filters for adding additional data. https://www.wpgraphql.com/filters

    Thread Starter Shashank Shekhar

    (@shashankitsoft)

    Thank you for quick response Paul. Firstly Kudos for your great plugin for other promising features. But Graphql is now very common now a day for modern apps while using wordpress as a headless backend.

    The https://docs.pods.io/code/wpgraphql-integration/ I checked, mentioned “Coming Soon support for Settings Page” https://pods-pro.skc.dev/downloads/wpgraphql-integration/ , got its in development. Any idea when its planned to provide that important function?

    I see WPGraphQL filters link, thanks, but in Pods Settings Page fields case, the fields are being created dynamically in database, not a fixed name/code portion on which I can apply some filters or things.

    Can you please provide a sample hook code portion, at least a pseudo code, how I can attach the newly created fields via pods to capture in graphql?

    Plugin Support Paul Clark

    (@pdclark)

    It is not imminent. Arbitrary exposure of data from options requires security checks.

    The Pods settings follow a standard format stored in wp_options table where the key is the Pod / Settings Page name followed by an underscore followed by the field name.

    get_option( 'podname_fieldname' );
    Thread Starter Shashank Shekhar

    (@shashankitsoft)

    Thank you for the hint Paul, I will look and try doing it with some code meanwhile.
    Will be hoping although this important thing will be built in the Pods in near time when possible.

    Plugin Support Paul Clark

    (@pdclark)

    There are many examples at https://www.wpgraphql.com/recipes

    For example https://www.wpgraphql.com/recipes/list-of-key-values where value1 value2 value3 would be the get_option() calls and the field name is listOfKeyValues.

    https://www.wpgraphql.com/recipes/add-field-to-output-urls-for-sitemap and s basically the same thing but field name allUrls.

    Plugin Support Paul Clark

    (@pdclark)

    Thanks and best of luck with the recipes.

    Votes for feature prioritization can be cast via Friends of Pods.

    In the meantime, the recipes above will require one to two lines to be modified to accommodate the requirement.

    Thread Starter Shashank Shekhar

    (@shashankitsoft)

    Thank you very much much Paul.
    I also was checking (although may be you have already checked), as per the official wpgraphql guide: https://www.wpgraphql.com/docs/settings#registering-custom-settings

    function register_my_setting() {
        $args = [
          'type' => 'string',
          'sanitize_callback' => 'sanitize_text_field',
          'default' => NULL,
          'show_in_graphql' => true, // This tells WPGraphQL to show this setting in the Schema
        ];
        register_setting( 'my_options_group', 'my_option_name', $args );
    }
    
    add_action( 'init', 'register_my_setting' );

    If Pods plugin be registering its fields group and fields with ‘show_in_graphql’ => true while saving configurations, the wordpress will be itself handle its security and access, and the group with fields be accessible with graphql query:

    {
      myOptionsGroupSettings {
        myOptionName
      }
    }

    https://www.wpgraphql.com/docs/settings#site-settings-by-settings-group
    The mentioned links says that, I am not aware for deep data-format or compatibility with Pods plugin if any, as you know better being the plugin author, but looking on this it seems may be a small tweak in saving ‘setting page’ settings by Pods plugin may make it work self (handling permission/security by wp self further).

    Plugin Support Paul Clark

    (@pdclark)

    Thanks for the notes.
    The challenge with providing a generic UI for settings access is that WP does not handle any access controls in that registration by default. It would expose the setting to unauthenticated users. Adding user interface which includes access controls per-field takes time and testing, as any oversight in generic registration or implications of its use would potentially expose things that tend to be in the options table… authentication keys etc.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘GraphQL for Pods Settings Page Fields’ is closed to new replies.