PHPackages                             rozbehsharahi/graphql3 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rozbehsharahi/graphql3

ActiveTypo3-cms-extension[API Development](/categories/api)

rozbehsharahi/graphql3
======================

A GraphQL extension for TYPO3

v2.0.2(9mo ago)92421[1 PRs](https://github.com/RozbehSharahi/graphql3/pulls)GPL-3.0-or-laterPHPPHP &gt;=8.2CI passing

Since Nov 1Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/RozbehSharahi/graphql3)[ Packagist](https://packagist.org/packages/rozbehsharahi/graphql3)[ RSS](/packages/rozbehsharahi-graphql3/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (24)Used By (0)

GraphQL3
========

[](#graphql3)

---

> **This extension lacks testing of real users. The more users report issues and create PRs, the more you can trust in its production readiness**. Currently there is not much movement. You are very welcome to contribute by testing and using the [issue board](https://github.com/RozbehSharahi/graphql3/issues).

> With version 2.0.0, TYPO3 11 is no longer supported. Make sure to have php &gt;= 8.2 and TYPO3 12 or 13 installed

---

This package enables you to register a graphql schema for your TYPO3 page.

If you register a schema, it is accessible via the tail `/graphql` or `/graphiql` on your site's root-page:

>
>  (TYPO3\_CONTEXT=Development only)

Installation
------------

[](#installation)

```
composer require rozbehsharahi/graphql3
```

Usage
-----

[](#usage)

Schemas are registered using `webonyx/graphql-php` package types.

Documentation:

Schematically the usage of `graphql3` is as following:

```
use GraphQL\Type\Schema;
use RozbehSharahi\Graphql3\Registry\SchemaRegistry;

/** @var SchemaRegistry $schemaRegistry */
$schemaRegistry->registerCreator(fn() => new Schema([
    'query' => new ObjectType([
        'name' => 'Query',
        'fields' => [
            'noop' => [
                'type' => Type::string(),
                'resolve' => fn () => 'noop',
            ],
        ],
    ]),
]))
```

After that you should already be able to access your graphql endpoint.

The method `register` expects a schema of `webonyx/graphql-php` package, so you are free to do whatever you wish from here on.

However, the main focus of `graphql3` is providing extendable builders/types/nodes/resolvers, which will facilitate the introduction of GraphQL on TYPO3 sites.

For instance the following code is completely equivalent, but uses one of the in-house types.

```
use RozbehSharahi\Graphql3\Registry\SchemaRegistry;
use RozbehSharahi\Graphql3\Type\NoopQueryType;

/** @var SchemaRegistry $schemaRegistry */
$schemaRegistry->registerCreator(fn () => (new NoopQueryType());
```

In order to have some real working TYPO3 code, continue to the next chapter `Getting started`.

Getting started
===============

[](#getting-started)

We assume you have a working TYPO3 extension and a `Configuration/Services.yaml` (as following), which will make constructor injection and service locating work.

```
services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false

  Your\Extension\:
    resource: '../Classes/*'
    exclude: '../Classes/Domain/Model/*'
```

Create a graphql setup class, somewhere in your extension's `Classes` directory.

```
