Monorepo of the PoP project, including: a server-side component model in PHP, a GraphQL server, a GraphQL API plugin for WordPress, and a website builder

Overview

PoP

PoP is a monorepo containing several projects.

The GraphQL API for WordPress plugin

GraphQL API for WordPress is a forward-looking and powerful GraphQL server for WordPress.

Plugins can extend the GraphQL schema, to fetch their own data.

GraphQL By PoP

GraphQL by PoP is a CMS-agnostic GraphQL server in PHP.

PoP - set of PHP components

PoP is a set of libraries which provide a server-side component model in PHP, and the foundation to implement applications with it.

  • Website: getpop.org
  • Source code:
    • Engine: The basic libraries.
    • Schema: The definitions for data entities (posts, users, comments, etc).
    • API: Packages to access the schema data through an API, including REST and GraphQL.

Site Builder (WIP)

Site Builder is a set of PHP components to build a website using PoP's component-model architecture.

Similar to WordPress, it accepts themes.


Table of Contents

  1. Setting-up the development environment
  2. Layer dependency graph
  3. Supported PHP features
  4. How is the GraphQL server CMS-agnostic
  5. Why are there so many packages in the repo
  6. Why a monorepo
  7. How transpiling works
  8. How scoping works
  9. Installing the GraphQL API for WordPress plugin

Standards

PSR-1, PSR-4 and PSR-12.

To check the coding standards via PHP CodeSniffer, run:

composer check-style

To automatically fix issues, run:

composer fix-style

Testing

To execute PHPUnit, run:

composer test

Static analysis

To execute PHPStan, run:

composer analyse

Previewing code downgrade

Via Rector (dry-run mode):

composer preview-code-downgrade

Report issues

Use the issue tracker to report a bug or request a new feature for all packages in the monorepo.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

GNU General Public License v2 (or later). Please see License File for more information.

Comments
  • Please raise visibility of Contributing

    Please raise visibility of Contributing

    In the README you don't really find the Contributing section, and it is so short one may think I should not really contribute here. Please consider this.

    opened by szepeviktor 38
  • Integrate with ZeroNet?

    Integrate with ZeroNet?

    Read discussion below.

    Note: previously this issue was about integration with React. But since the conversation on ZeroNet took over, I just renamed this issue.

    enhancement question 
    opened by leoloso 23
  • Analyze using `block.json` to register Gutenberg blocks in the GraphQL schema

    Analyze using `block.json` to register Gutenberg blocks in the GraphQL schema

    block.json will be available starting from WordPress 5.8 to register block types. The GraphQL API could read this information and, dynamically, create types for these blocks, to be registered in the schema.

    Analyze if this path is doable, advantages and potential problems from implementing this approach.

    References:

    Compare approach against:

    Schema gutenberg 
    opened by leoloso 9
  • Sharing variables and objects is a basic necessity

    Sharing variables and objects is a basic necessity

    From https://github.com/leoloso/PoP/blob/f134be00ccf8e4b4ce788dbd4d801e5641834b3a/layers/GraphQLAPIForWP/plugins/graphql-api-for-wp/phpstan.neon.dist#L13

    Detailed description

    🦕

    Global constants return \GRAPHQL_API_DIR; and static properties, functions protected static $instance;

    👴

    A DI container and an immutable container are the object oriented solutions. Available since early PHP versions.

    I let you take the wheel!

    opened by szepeviktor 7
  • PHP Notice(s): is_singular was called incorrectly & undefined index

    PHP Notice(s): is_singular was called incorrectly & undefined index

    Detailed description

    Getting a couple PHP Notices when following the composer install steps.

    is_singlular

    PHP Notice:  is_singular was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in /usr/local/wordpress/wp-includes/functions.php on line 5458
    [24-Jun-2021 16:30:32 UTC] PHP Stack trace:
    [24-Jun-2021 16:30:32 UTC] PHP   1. {main}() /usr/local/wordpress/wp-admin/admin-ajax.php:0
    [24-Jun-2021 16:30:32 UTC] PHP   2. require_once() /usr/local/wordpress/wp-admin/admin-ajax.php:22
    [24-Jun-2021 16:30:32 UTC] PHP   3. require_once() /usr/local/wordpress/wp-load.php:50
    [24-Jun-2021 16:30:32 UTC] PHP   4. require_once() /usr/local/wordpress/wp-config.php:151
    [24-Jun-2021 16:30:32 UTC] PHP   5. do_action($hook_name = 'plugins_loaded') /usr/local/wordpress/wp-settings.php:441
    [24-Jun-2021 16:30:32 UTC] PHP   6. WP_Hook->do_action($args = [0 => '']) /usr/local/wordpress/wp-includes/plugin.php:470
    [24-Jun-2021 16:30:32 UTC] PHP   7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /usr/local/wordpress/wp-includes/class-wp-hook.php:327
    [24-Jun-2021 16:30:32 UTC] PHP   8. GraphQLAPI\GraphQLAPI\Plugin->bootApplication('') /usr/local/wordpress/wp-includes/class-wp-hook.php:303
    [24-Jun-2021 16:30:32 UTC] PHP   9. PoP\Root\AppLoader::bootApplication($cacheContainerConfiguration = TRUE, $containerNamespace = '_v0.7.13_1624552110_admin') /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/src/Plugin.php:280
    [24-Jun-2021 16:30:32 UTC] PHP  10. PoP\Engine\AppLoader::bootComponents() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/root/src/AppLoader.php:173
    [24-Jun-2021 16:30:32 UTC] PHP  11. PoP\Root\Managers\ComponentManager::beforeBoot() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/engine/src/AppLoader.php:19
    [24-Jun-2021 16:30:32 UTC] PHP  12. PoP\Root\Component::beforeBoot() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/root/src/Managers/ComponentManager.php:37
    [24-Jun-2021 16:30:32 UTC] PHP  13. PoP\Root\Container\ServiceInstantiator->initializeServices() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/root/src/Component.php:59
    [24-Jun-2021 16:30:32 UTC] PHP  14. GraphQLAPI\GraphQLAPI\ConditionalOnEnvironment\GraphiQLExplorerInCustomEndpointPublicClient\Overrides\Services\Clients\CustomEndpointGraphiQLWithExplorerClient->initialize() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/root/src/Container/ServiceInstantiator.php:28
    [24-Jun-2021 16:30:32 UTC] PHP  15. GraphQLAPI\GraphQLAPI\ConditionalOnEnvironment\GraphiQLExplorerInCustomEndpointPublicClient\Overrides\Services\Clients\CustomEndpointGraphiQLWithExplorerClient->isClientDisabled() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/graphql-by-pop/graphql-clients-for-wp/src/Clients/AbstractClient.php:27
    [24-Jun-2021 16:30:32 UTC] PHP  16. is_singular($post_types = 'graphql-endpoint') /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/src/Clients/CustomEndpointClientTrait.php:18
    [24-Jun-2021 16:30:32 UTC] PHP  17. _doing_it_wrong($function = 'is_singular', $message = 'Conditional query tags do not work before the query is run. Before then, they always return false.', $version = '3.1.0') /usr/local/wordpress/wp-includes/query.php:765
    [24-Jun-2021 16:30:32 UTC] PHP  18. trigger_error($message = 'is_singular was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.)', $error_type = 1024) /usr/local/wordpress/wp-includes/functions.php:5458
    

    Undefined index

    PHP Notice:  Undefined index:  in /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/migrate-component-model/migrate/kernel/strata/stratum-manager.php on line 42
    [24-Jun-2021 16:37:16 UTC] PHP Stack trace:
    [24-Jun-2021 16:37:16 UTC] PHP   1. {main}() /usr/local/wordpress/wp-admin/admin-ajax.php:0
    [24-Jun-2021 16:37:16 UTC] PHP   2. require_once() /usr/local/wordpress/wp-admin/admin-ajax.php:22
    [24-Jun-2021 16:37:16 UTC] PHP   3. require_once() /usr/local/wordpress/wp-load.php:50
    [24-Jun-2021 16:37:16 UTC] PHP   4. require_once() /usr/local/wordpress/wp-config.php:151
    [24-Jun-2021 16:37:16 UTC] PHP   5. do_action($hook_name = 'wp_loaded') /usr/local/wordpress/wp-settings.php:600
    [24-Jun-2021 16:37:16 UTC] PHP   6. WP_Hook->do_action($args = [0 => '']) /usr/local/wordpress/wp-includes/plugin.php:470
    [24-Jun-2021 16:37:16 UTC] PHP   7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /usr/local/wordpress/wp-includes/class-wp-hook.php:327
    [24-Jun-2021 16:37:16 UTC] PHP   8. PoP\EngineWP\LooseContracts\LooseContractResolutionSet->PoP\EngineWP\LooseContracts\{closure:/usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/engine-wp/src/LooseContracts/LooseContractResolutionSet.php:23-25}('') /usr/local/wordpress/wp-includes/class-wp-hook.php:303
    [24-Jun-2021 16:37:16 UTC] PHP   9. PoP\HooksWP\HooksAPI->doAction($tag = 'popcms:boot') /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/engine-wp/src/LooseContracts/LooseContractResolutionSet.php:24
    [24-Jun-2021 16:37:16 UTC] PHP  10. do_action($hook_name = 'popcms:boot') /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/hooks-wp/src/HooksAPI.php:40
    [24-Jun-2021 16:37:16 UTC] PHP  11. WP_Hook->do_action($args = [0 => '']) /usr/local/wordpress/wp-includes/plugin.php:470
    [24-Jun-2021 16:37:16 UTC] PHP  12. WP_Hook->apply_filters($value = '', $args = [0 => '']) /usr/local/wordpress/wp-includes/class-wp-hook.php:327
    [24-Jun-2021 16:37:16 UTC] PHP  13. PoPSchema\UserStateAccessControl\Hooks\DisableDirectivesIfUserIsLoggedInConfigurableAccessControlForDirectivesInPrivateSchemaHookSet->cmsBoot('') /usr/local/wordpress/wp-includes/class-wp-hook.php:303
    [24-Jun-2021 16:37:17 UTC] PHP  14. PoPSchema\UserStateAccessControl\Hooks\DisableDirectivesIfUserIsLoggedInConfigurableAccessControlForDirectivesInPrivateSchemaHookSet->enabled() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/access-control/src/Hooks/AbstractAccessControlForDirectivesHookSet.php:15
    [24-Jun-2021 16:37:17 UTC] PHP  15. PoP\ComponentModel\State\ApplicationState::getVars() /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/pop-schema/user-state-access-control/src/Hooks/AbstractUserStateConfigurableAccessControlForDirectivesInPrivateSchemaHookSet.php:14
    [24-Jun-2021 16:37:17 UTC] PHP  16. PoP\ComponentModel\StratumManager->getStrata($stratum = NULL) /usr/local/wordpress/wp-content/plugins/graphql-api-for-wp/vendor/getpop/component-model/src/State/ApplicationState.php:96
    

    Context

    WP_DEBUG=true

    Your environment

    Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

    | Software | Version | | --- | --- | | GraphQL API plugin | 0.7.13 | | PHP | 7.4 | | WordPress | 5.7.2 | | Gutenberg | NA |

    opened by thefrosty 5
  • Implement Code Splitting

    Implement Code Splitting

    The idea is to initially load assets as small as they can be, containing only what is needed for that page (JS, CSS, Handlebars templates) and nothing more. This way, loading the first page will get a significant performance boost.

    The challenge is how to make it work with the "previous session openTabs()" functionality, which allows the user to immediately open many more pages to the current one, possibly from pages cached using Service Workers. This implies that, by the time these pages from the Service Workers cache are loaded (which is pretty much immediately), their assets must also have been pre-loaded.

    Can that be achieved using code-splitting? If so, will the code be manageable? (eg: importing all the Handlebars templates one per file is not pretty... it's normally nicer to import them as a bundle.) Does it make sense to implement it?

    As a reference, WebPack is doing code-splitting

    enhancement new feature 
    opened by leoloso 5
  • Create script to create pages/categories/etc needed for configuration

    Create script to create pages/categories/etc needed for configuration

    Most plug-ins need some configuration to be done, which involves creating pages (eg: POPTHEME_WASSUP_PAGE_ADDCONTENT) / categories (eg: POPTHEME_WASSUP_CAT_WEBPOSTS) / etc in the system, and then saving their IDs in a configuration file, such as environment-constants.php.

    The creation of these is currently a manual process. It would be awesome to automate it, adding scripts to create the objects in the DB upon installation of the plug-in, and then automatically saving the IDs on the configuration file.

    enhancement help wanted 
    opened by leoloso 5
  • Add a

    Add a "Regenerate schema" button on the plugin's Settings page?

    If implementing the approach from #741, the schema may need be regenerated when a WordPress plugin containing blocks is installed, i.e. not under the control of the GraphQL API for WP.

    Then, consider to allow users to regenerate the schema manually, by placing a "Regenerate schema" button on the Settings page. When pressed, it must simply delete the container timestamp from the DB, and next time the plugin is accessed, it will be regenerated.

    question GraphQL API for WP 
    opened by leoloso 4
  • WordPress 5.8 Support

    WordPress 5.8 Support

    Detailed description

    I am running WordPress 5.8 beta 2 and am getting deprecated notices on block_editor_preload_paths

    PHP Deprecated:  block_editor_preload_paths is <strong>deprecated</strong> since version 5.8.0! Use block_editor_rest_api_preload_paths instead. in /usr/local/wordpress/wp-includes/functions.php on line 5381
    [24-Jun-2021 17:03:38 UTC] PHP Stack trace:
    [24-Jun-2021 17:03:38 UTC] PHP   1. {main}() /usr/local/wordpress/wp-admin/post-new.php:0
    [24-Jun-2021 17:03:38 UTC] PHP   2. require() /usr/local/wordpress/wp-admin/post-new.php:72
    [24-Jun-2021 17:03:38 UTC] PHP   3. block_editor_rest_api_preload($preload_paths = [0 => '/', 1 => '/wp/v2/types?context=edit', 2 => '/wp/v2/taxonomies?per_page=-1&context=edit', 3 => '/wp/v2/themes?status=active', 4 => '/wp/v2/graphql-query/3620893?context=edit', 5 => '/wp/v2/types/graphql-query?context=edit', 6 => '/wp/v2/users/me?post_type=graphql-query&context=edit', 7 => [0 => '/wp/v2/media', 1 => 'OPTIONS'], 8 => [0 => '/wp/v2/blocks', 1 => 'OPTIONS'], 9 => '/wp/v2/graphql-query/3620893/autosaves?context=edit'], $block_editor_context = class WP_Block_Editor_Context { public $post = class WP_Post { public $ID = 3620893; public $post_author = '2'; public $post_date = '2021-06-24 10:03:38'; public $post_date_gmt = '0000-00-00 00:00:00'; public $post_content = ''; public $post_title = ''; public $post_excerpt = ''; public $post_status = 'auto-draft'; public $comment_status = 'closed'; public $ping_status = 'closed'; public $post_password = ''; public $post_name = ''; public $to_ping = ''; public $pinged = ''; public $post_modified = '2021-06-24 10:03:38'; public $post_modified_gmt = '0000-00-00 00:00:00'; public $post_content_filtered = ''; public $post_parent = 0; public $guid = 'https://bodcms.test/?post_type=graphql-query&p=3620893'; public $menu_order = 0; public $post_type = 'graphql-query'; public $post_mime_type = ''; public $comment_count = '0'; public $filter = 'raw' } }) /usr/local/wordpress/wp-admin/edit-form-blocks.php:69
    [24-Jun-2021 17:03:38 UTC] PHP   4. apply_filters_deprecated($hook_name = 'block_editor_preload_paths', $args = [0 => [0 => '/', 1 => '/wp/v2/types?context=edit', 2 => '/wp/v2/taxonomies?per_page=-1&context=edit', 3 => '/wp/v2/themes?status=active', 4 => '/wp/v2/graphql-query/3620893?context=edit', 5 => '/wp/v2/types/graphql-query?context=edit', 6 => '/wp/v2/users/me?post_type=graphql-query&context=edit', 7 => [...], 8 => [...], 9 => '/wp/v2/graphql-query/3620893/autosaves?context=edit'], 1 => class WP_Post { public $ID = 3620893; public $post_author = '2'; public $post_date = '2021-06-24 10:03:38'; public $post_date_gmt = '0000-00-00 00:00:00'; public $post_content = ''; public $post_title = ''; public $post_excerpt = ''; public $post_status = 'auto-draft'; public $comment_status = 'closed'; public $ping_status = 'closed'; public $post_password = ''; public $post_name = ''; public $to_ping = ''; public $pinged = ''; public $post_modified = '2021-06-24 10:03:38'; public $post_modified_gmt = '0000-00-00 00:00:00'; public $post_content_filtered = ''; public $post_parent = 0; public $guid = 'https://bodcms.test/?post_type=graphql-query&p=3620893'; public $menu_order = 0; public $post_type = 'graphql-query'; public $post_mime_type = ''; public $comment_count = '0'; public $filter = 'raw' }], $version = '5.8.0', $replacement = 'block_editor_rest_api_preload_paths', $message = *uninitialized*) /usr/local/wordpress/wp-includes/block-editor.php:435
    [24-Jun-2021 17:03:38 UTC] PHP   5. _deprecated_hook($hook = 'block_editor_preload_paths', $version = '5.8.0', $replacement = 'block_editor_rest_api_preload_paths', $message = '') /usr/local/wordpress/wp-includes/plugin.php:654
    [24-Jun-2021 17:03:38 UTC] PHP   6. trigger_error($message = 'block_editor_preload_paths is <strong>deprecated</strong> since version 5.8.0! Use block_editor_rest_api_preload_paths instead.', $error_type = 16384) /usr/local/wordpress/wp-includes/functions.php:5381
    [24-Jun-2021 17:03:39 UTC] PHP Deprecated:  block_categories is <strong>deprecated</strong> since version 5.8.0! Use block_categories_all instead. in /usr/local/wordpress/wp-includes/functions.php on line 5381
    

    Context

    Looks like loading of the custom Query pages are broken: /wp-admin/post-new.php?post_type=graphql-query

    Your environment

    Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

    | Software | Version | | --- | --- | | GraphQL API plugin | 0.7.13 | | PHP | 7.4 | | WordPress | 5.8 beta 2 | | Gutenberg | NA |

    opened by thefrosty 4
  • Fragments are not resolved properly

    Fragments are not resolved properly

    This query fails:

    /?
    query=
      __schema.
        type(name:"Root").
          --FullType
    &fragments[FullType]=
      name|
      fields(includeDeprecated: true)[@fields].
        name|
        args.
          --InputValue,
      [fields].
        type.
          name
    &fragments[InputValue]=
      id
    

    with error Fragment 'InputValue,[fields]' is undefined, so it has been ignored.

    The problem happens in --InputValue,[fields]. If we remove any of those subqueries (either the fragment or the bookmark) it works well

    wontfix Field Query 
    opened by leoloso 4
  • Release standalone plug-ins for several functionalities

    Release standalone plug-ins for several functionalities

    The PoP engine can run on any WordPress website, so it makes sense to provide standalone functionalities, independently of the website using a PoP theme or not. Eg:

    • Comments
    • Front-end editor
    • Search/typeahead input
    • Media player
    • User notifications
    • Messaging
    enhancement help wanted 
    opened by leoloso 4
  • Downgrade `Redis6Proxy.php` once there's Rector rule to downgrade `#SensitiveParameter`

    Downgrade `Redis6Proxy.php` once there's Rector rule to downgrade `#SensitiveParameter`

    These files are currently skipped downgrading:

    • vendor/symfony/cache/Traits/Redis6Proxy.php
    • vendor/symfony/cache/Traits/RedisCluster6Proxy.php

    That's because they produce this error:

    ------------------------------------------------------------
    Parse error: vendor/symfony/cache/Traits/Redis6Proxy.php:103
        101|      */
        102|     public function auth(#[\SensitiveParameter] $credentials)
      > 103|     {
        104|         return $this->lazyObjectReal->auth(...\func_get_args());
        105|     }
    Unexpected '{', expecting variable (T_VARIABLE) in vendor/symfony/cache/Traits/Redis6Proxy.php on line 103
    ------------------------------------------------------------
    Parse error: vendor/symfony/cache/Traits/RedisCluster6Proxy.php:38
        36| 
        37|     public function __construct($name, $seeds = null, $timeout = 0, $read_timeout = 0, $persistent = false, #[\SensitiveParameter] $auth = null, $context = null)
      > 38|     {
        39|         return $this->lazyObjectReal->__construct(...\func_get_args());
        40|     }
    Unexpected '{', expecting variable (T_VARIABLE) in vendor/symfony/cache/Traits/RedisCluster6Proxy.php on line 38
    

    #[\SensitiveParameter] is a new attribute added to PHP 8.2. Once there's a Rector rule to downgrade it, the 2 files can be added once again.

    maintenance 
    opened by leoloso 0
  • Upgrade to GraphiQL v2.0 (or v3.0?), using the built-in Explorer plugin

    Upgrade to GraphiQL v2.0 (or v3.0?), using the built-in Explorer plugin

    The new GraphiQL v2.0 has the Explorer already integrated as a plugin:

    • https://github.com/graphql/graphiql/tree/main/packages/graphiql
    • https://github.com/graphql/graphiql/tree/main/packages/graphiql-plugin-explorer

    Upgrade GraphiQL to either v2.0 or v3.0 (where the Explorer will be bundled more natively), and then remove module "GraphiQL Explorer" from the GraphQL API plugin, which will not make sense anymore.

    GraphQL API for WP client 
    opened by leoloso 1
  • Use actual PHP 8.1 Enums in the `EnumTypeResolver`, once Rector fully supports downgrading it

    Use actual PHP 8.1 Enums in the `EnumTypeResolver`, once Rector fully supports downgrading it

    Currently Rector does not fully support downgrading PHP 8.1 Enums (see https://github.com/rectorphp/rector/issues/7013#issuecomment-1228147159).

    When full support is provided, continue working on branch Use-Enum-in-EnumTypeResolver.

    maintenance 
    opened by leoloso 0
  • Print the error

    Print the error "path" in the GraphQL response

    In the Error result format section of the GraphQL spec it reads:

    If an error can be associated to a particular field in the GraphQL result, it must contain an entry with the key path that details the path of the response field which experienced the error. This allows clients to identify whether a null result is intentional or caused by a runtime error.

    This field should be a list of path segments starting at the root of the response and ending with the field associated with the error. Path segments that represent fields should be strings, and path segments that represent list indices should be 0-indexed integers. If the error happens in an aliased field, the path to the error should use the aliased name, since it represents a path in the response, not in the request.

    Implement this feature.

    Important

    Please notice that currently there is extensions.path printed in the response, but this points to the AST node where the error happens, whereas the GraphQL spec instead points to the place in the response where the value is printed as null

    To avoid confusion, the current extensions.path should be renamed to something else (eg: extensions.astPath).

    Implementation

    A data structure storing which Fields produced an error must be created and deal with in parallel to $resolvedIDFieldValues. This solution can also support bubbling the null upwards:

    • #1457
    GraphQL spec 
    opened by leoloso 0
  • Use PHP 7.1 in InstaWP, when available

    Use PHP 7.1 in InstaWP, when available

    InstaWP is used to execute integration tests. As the GraphQL API plugin is downgraded to PHP 7.1, we should test against this version, however currently InstaWP only supports PHP 7.2 as its minimum PHP version.

    InstaWP founder Vikas Singhal told me it would be ready in 6 to 8 weeks. When this is done, change the InstaWP template to use PHP 7.1.

    maintenance 
    opened by leoloso 0
  • Further develop (and document) how the GraphQL API can help import data from an external site to the WordPress site

    Further develop (and document) how the GraphQL API can help import data from an external site to the WordPress site

    The GraphQL API has a few features that make it easy to access the data from an external endpoint, manipulate it, and inject it into some other field or mutation, allowing a single GraphQL query to perform complex operations. For instance, it allows importing posts/users/categories/tags/etc from another site (whether it is WordPress or not) into the WordPress site, without the need to write custom resolvers!.

    The procedure could be something like this:

    • A field rearrangeJSONObjectProperties($input: JSONObject, $fromToPropertyPaths: JSONObject) can manipulate the entries in an input, renaming the keys into the desired output
    • Via the "Resolved Field Variable Reference" feature, the output of the previous field can be accessed as an input into another field/mutation
    • Using the "Multiple Query Execution" feature we can export a JSONObject that is treated as the expected input type for some mutation (eg: PostInput, UserInput, etc)
    • In the subsequent query, check if the data already exists
    • If not, create it

    For instance, this (potential) query accesses user data from an external REST endpoint, checks if the user exists on the local site and, if not, it creates it:

    query ExportUserData
    {
      externalData: restData(url: "https://some-other-site.com/rest/users")
      userData: rearrangeJSONObjectProperties(
        # Using "Resolved Field Variable Reference" to access some resolved value as an input to another field
        input: $externalData,
        fromToPropertyPaths: {
          "user.name": "name",
          "user.email": "email"
        }
      )
        # Using "Multiple Query Execution" to export a value
        @export(as: "userInput")
      extract(object: $userData, path: "email")
        @export(as: "userEmail")
    }
    
    query CheckUserExists($userEmail: String)
      @dependsOn(operation: "ExportUserData")
    {
      userExists(userEmail: $userEmail) @export(as: "doesUserExist")
    }
    
    mutation CreateUser($doesUserExist: Boolean, $userInput: UserInput)
      @dependsOn(operation: "CheckUserExists")
      @execute(if: $doesUserExist)
    {
      createUser(input: $userInput) {
        id
        name
        email
      }
    }
    

    Notice how $userInput is exported as a JSONObject, but is then treated as a UserInput in the following mutation. That casting of the type should already work.

    Directives @dependsOn and @execute do not currently exist, but they can be implemented once "operation directives" are supported (currently they are not).

    If the external endpoint is REST, a single rest field to get its data may be sufficient. If it is GraphQL, then using a new CPT called ExternalEndpoint might be better as to specify the GraphQL query:

    query ExportUserData
    {
      externalData: externalEndpointData(cptSlug: "some-graphql-external-endpoint-for-client")
      # ...
    }
    
    GraphQL API for WP 
    opened by leoloso 0
Releases(0.8.1)
Owner
Leonardo Losoviz
Creator of the GraphQL API for WordPress. Contributing writer for CSS-Tricks, the LogRocket blog, Design Bombs and Smashing Magazine
Leonardo Losoviz
EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

WPGraphQL Block Editor This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on

WPGraphQL 29 Nov 18, 2022
Facebook Query Builder: A query builder for nested requests in the Facebook Graph API

A query builder that makes it easy to create complex & efficient nested requests to Facebook's Graph API to get lots of specific data back with one request.

Sammy Kaye Powers 92 Dec 18, 2022
Add Price Including tax for Magento's "cart" GraphQl query

Comwrap_GraphQlCartPrices Add Price Including tax for Magento's "cart" GraphQl query Query will looks like following: items { id __typenam

Comwrap 1 Dec 2, 2021
Syntax to query GraphQL through URL params, which grants a GraphQL API the capability to be cached on the server.

Field Query Syntax to query GraphQL through URL params, which grants a GraphQL API the capability to be cached on the server. Install Via Composer com

PoP 4 Jan 7, 2022
The server component of API Platform: hypermedia and GraphQL APIs in minutes

API Platform Core API Platform Core is an easy to use and powerful system to create hypermedia-driven REST and GraphQL APIs. It is a component of the

API Platform 2.2k Dec 27, 2022
GraphQL API to Studio Ghibli REST API

GhibliQL GhibliQL is a GraphQL wrapper to the Studio Ghibli REST API Usage First, you'll need a GraphQL client to query GhibliQL, like GraphQL IDE Con

Sebastien Bizet 8 Nov 5, 2022
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

Luracast 1.4k Dec 14, 2022
Pure PHP implementation of GraphQL Server – Symfony Bundle

Symfony GraphQl Bundle This is a bundle based on the pure PHP GraphQL Server implementation This bundle provides you with: Full compatibility with the

null 283 Dec 15, 2022
Test your PHP GraphQL server in style, with Pest!

Pest GraphQL Plugin Test your GraphQL API in style, with Pest! Installation Simply install through Composer! composer require --dev miniaturebase/pest

Minibase 14 Aug 9, 2022
GraPHPinator ⚡ 🌐 ⚡ Easy-to-use & Fast GraphQL server implementation for PHP

Easy-to-use & Fast GraphQL server implementation for modern PHP. Includes features from latest draft, middleware directives and modules with extra functionality.

Infinityloop.dev 34 Dec 14, 2022
A simple facade for managing the relationship between your model and API.

Table of Contents PhpGrape\Entity Introduction Installation Example Reusable Responses with Entities Defining Entities Basic Exposure Exposing with a

null 2 Oct 7, 2022
This bundle provides tools to build a complete GraphQL server in your Symfony App.

OverblogGraphQLBundle This Symfony bundle provides integration of GraphQL using webonyx/graphql-php and GraphQL Relay. It also supports: batching with

Webedia - Overblog 720 Dec 25, 2022
application/hal builder / formatter for PHP 5.4+

Nocarrier\Hal This is a library for creating documents in the application/hal+json and application/hal+xml hypermedia formats It requires PHP 5.4 or l

Ben Longden 204 Sep 28, 2022
This project lists all the mandatory steps I recommend to build a Website using Symfony, Twig, Doctrine.

{% raw %} <-- keep this for Jekyll to fully bypass this documents, because of the Twig tags. Symfony Website Checklist ?? Summary~~~~ Elevator pitch P

William Pinaud 6 Aug 31, 2022
Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota & International

Courier API Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota (dalam negeri) & International

Rangga Darmajati 2 Sep 24, 2021
IMAGON is an image optimization and compression API Free, that helps improve your website performance.

IMAGON API Demo Image Optimization and Compression API by IMAGON IMAGON is an image optimization and compression API Free, that helps improve your web

Nashwan Abdullah 3 Jan 15, 2022
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.

API Platform is a next-generation web framework designed to easily create API-first projects without compromising extensibility and flexibility: Desig

API Platform 7.7k Jan 7, 2023
A Statamic Pro addon that provides alternative GraphQL queries for collections, entries and global sets.

Statamic Enhanced GraphQL A Statamic CMS GraphQL Addon that provides alternative GraphQL queries for collections, entries and global sets. ⚠️ This is

Grischa Erbe 2 Dec 7, 2021
Proposed REST and GraphQL APIs for Concrete CMS 9.2+

Concrete CMS API Proposal 2022 Hello there! This is a package for Concrete CMS (9.1.1+) that adds a proposed REST API. This API is reasonably comprehe

Concrete CMS 5 Aug 11, 2022