Jump to content

Extension:GraphQL

From mediawiki.org
MediaWiki extensions manual
GraphQL
Release status: experimental
Implementation API
Description GraphQL proxy for the Action API
Author(s) David Barratt (DBarratt (WMF)talk)
MediaWiki >= 1.35
PHP < 8.0
License GNU General Public License 3.0 or later
Download
  • $wgGraphQLValidateSchema
Quarterly downloads 1 (Ranked 135th)
Translate the GraphQL extension if it is available at translatewiki.net
Issues Open tasks ¡ Report a bug

GraphQL extension exposes a /graphql endpoint in MediaWiki as a proxy for the Action API and REST API.

Installation

[edit]
  • Download and move the extracted GraphQL folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GraphQL
  • Only when installing from Git, run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'GraphQL' );
    
  • Install npm dependencies with npm install in the extension directory
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

[edit]
  • The GraphQL endpoint is exposed at Special:GraphQL with an alias at /graphql.
  • The GraphQL Sandbox can be accessed at Special:GraphQLSandbox. The sandbox uses the GraphiQL in-browser GraphQL IDE.
  • The federation service endpoint is exposed at Special:GraphQL/Federation with an alias at /graphql/federation.

Project Goals

[edit]
  1. A proxy for the Action API and REST API. This extension should not expose functionality that is not already available in the existing APIs. This extension will therefore exist as a convenience to developers making bulk or recursive requests to the existing APIs.
  2. A federated service. This extension should be compatible with Apollo's Federation Specification or other federated specifications to allow a centralized gateway like Tool:GraphQL to make distributed GraphQL queries.