Search by

besmartand-pro / graphqlite-bundle

roszkiewiczjakub

A Symfony bundle for thecodingmachine/graphqlite.

Package info

github.com/BeSmartAnd-Pro/graphqlite-bundle

Type:symfony-bundle

pkg:composer/besmartand-pro/graphqlite-bundle

Statistics

Installs: 2 139

Dependents: 0

Suggesters: 0

Stars: 0

4.0.0 2026-09-16 12:08 UTC

README

Latest Stable Version License Build Status

GraphQLite bundle

Symfony bundle for the thecodingmachine/graphqlite package. It discovers your annotated controllers and types, builds the schema, exposes the /graphql endpoint through a PSR-7 bridge (with optional upload handling), and keeps the Symfony request available as the GraphQL context.

Part of the bundle docs: https://graphqlite.thecodingmachine.io/docs/symfony-bundle

See thecodingmachine/graphqlite.

Requirements

  • PHP 8.2+ and Composer 2
  • Supports:
    • Symfony ^7.4 or ^8.0 (Symfony 8 requires PHP 8.4+)
    • GraphQLite ^8.3.1

Installation

composer require besmartand-pro/graphqlite-bundle:^4.0

Enable the bundle in config/bundles.php if it is not already registered:

TheCodingMachine\GraphQLite\Bundle\GraphQLiteBundle::class => ['all' => true],

Configure routes

Import the bundle routes to expose /graphql:

# config/routes/graphqlite.yaml
graphqlite_bundle:
  resource: '@GraphQLiteBundle/Resources/config/routes.php'

Configure namespaces

Configure independent schemas using the fork's namespaces map. Each schema may scan several PHP namespaces:

# config/packages/graphqlite.yaml
graphqlite:
  namespaces:
    default:
      controllers: App\GraphQL\PublicApi\Controller
      types:
        - App\GraphQL\PublicApi\Type
        - App\Entity
    admin:
      controllers:
        - App\GraphQL\AdminApi\Controller
        - App\GraphQL\Reports\Controller
      types: App\GraphQL\AdminApi\Type

The default schema is served at /graphql and /graphql/default; admin is served at /graphql/admin. Unknown schema names return HTTP 404. A default schema is optional. Schema names accept letters, digits, underscores and hyphens. Keep scanned PHP namespaces disjoint where endpoints must expose different operations. Endpoint selection does not grant authorization: configure Symfony firewalls/access control for private endpoints.

The upstream single-schema namespace: {controllers: ..., types: ...} configuration is also accepted as default; do not combine it with namespaces.default. Security/debug options and explicitly tagged GraphQL services apply to every schema. Each schema has a separate discovery cache and request context.

php bin/console graphqlite:dump-schema admin
php bin/console graphqlite:dump-schema default --output=schema.graphql

Upgrading from 3.x

  • Keep existing namespaces configuration and graphqlite_endpoint route name.
  • Update PHP to 8.2+ and Symfony to 7.4+ (or Symfony 8 with PHP 8.4+).
  • Bundle sources moved to src/; PSR-4 class names and bundle route imports remain unchanged.
  • Keep besmartand-pro/graphqlite-symfony-validator-bridge; version ^1.1 retains the fork's validation exception changes.
  • GraphQLiteController now takes ServerConfigManager, followed by the optional PSR HTTP factory, debug flag and HTTP status decider. Update manual controller construction if applicable.
  • Default Schema, SchemaFactory and ServerConfig service aliases exist only when a default schema is configured.
  • Development uses PHPUnit 11.5 and PHPStan 2. The abandoned composer/package-versions-deprecated dependency is removed; Composer's native InstalledVersions API is used by the upstream tests.

Quickstart

Create a controller with GraphQLite attributes:

<?php
// src/GraphQL/Controller/HelloController.php
namespace App\GraphQL\Controller;

use TheCodingMachine\GraphQLite\Annotations\Query;

final class HelloController
{
    #[Query]
    public function hello(string $name = 'world'): string
    {
        return sprintf('Hello %s', $name);
    }
}

Features

  • Auto-discovers controllers and types from configured namespaces and registers GraphQLite services, query providers, type mappers, and middleware through Symfony autoconfiguration
  • Ships a /graphql route that converts Symfony requests to PSR-7 and keeps the Symfony request in the GraphQL context
  • Passes the Symfony request as context to allow using them in queries/mutations
  • Supports multipart uploads when graphql-upload is installed
  • Integrates with Symfony Security for #[Logged]/#[Right] checks
  • Expose login/logout mutations plus a me query (opt-out)
  • Symfony Validator-based user input validation
  • Lets you cap introspection, query depth, and query complexity via configuration
  • Uses isolated Symfony PHP-file cache pools for each schema
  • Includes a graphqlite:dump-schema console command to export GraphQL SDL

GraphiQL (playground)

The bundle wires Overblog’s GraphiQL bundle if it is installed. See https://github.com/overblog/GraphiQLBundle for enabling the UI alongside the /graphql endpoint.

Development

  • Tests: vendor/bin/phpunit
  • Static analysis: composer phpstan