Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 2.07 KB

README.md

File metadata and controls

64 lines (47 loc) · 2.07 KB

Latest Stable Version License Build Status

GraphQLite bundle

Symfony bundle for GraphQLite: build a GraphQL API by adding PHP attributes (#[Query], #[Mutation], #[Type], #[Field]...) to your classes. The bundle exposes the /graphql endpoint and integrates GraphQLite with Symfony services, Security, Validator, file uploads and cache.

Documentation: docs/index.rst

Requirements

  • PHP 8.1+
  • Symfony 6.4, 7.x or 8.x
  • GraphQLite ^8

Quick start

  1. Install the bundle (Symfony Flex enables it and creates its configuration):

    composer require thecodingmachine/graphqlite-bundle
  2. Tell GraphQLite where your GraphQL classes live:

    # config/packages/graphqlite.yaml
    graphqlite:
        namespace:
            controllers: App\GraphQL\Controller\
            types:
                - App\Entity\
                - App\GraphQL\Input\
  3. Write your first query and call /graphql:

    // src/GraphQL/Controller/HelloController.php
    namespace App\GraphQL\Controller;
    
    use TheCodingMachine\GraphQLite\Annotations\Query;
    
    class HelloController
    {
        #[Query]
        public function hello(string $name = 'world'): string
        {
            return sprintf('Hello %s', $name);
        }
    }

Continue with the getting started tutorial.

Development

  • Tests: vendor/bin/simple-phpunit
  • Static analysis: composer phpstan
  • The code examples of docs/ are tested: they must stay identical to the classes of tests/DocsFixtures/ (see tests/DocsExamplesTest.php).