maxa-ondrej / nette-graphql
Nette Framework GraphQLite Integration Extension
1.2.2
2023-03-26 20:24 UTC
Requires
- php: ^8.0
- contributte/cache: ^v0.6.0
- contributte/di: ^0.5.0
- psr/cache: ^1.0
- psr/container: ^1.0
- thecodingmachine/graphqlite: ^v5.0.0
Requires (Dev)
- contributte/dev: ^0.3
- jetbrains/phpstorm-attributes: ^1.0
- mockery/mockery: ^1.3.0
- nelmio/alice: ^3.5.8
- nette/application: ^3.0
- nette/bootstrap: ^3.0
- ninjify/nunjuck: ^0.4
- orisai/coding-standard: ^2.2
- phpstan/phpstan: ^1.0
- phpstan/phpstan-nette: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- tracy/tracy: ^2.7
README
Usage
composer require maxa-ondrej/nette-graphql
Nette Framework Usage
config.neon
extensions: graphql: Maxa\Ondrej\Nette\GraphQL\DI\GraphQLExtension
MyPresenter.php
<?php declare(strict_types=1); namespace App\Presenters; use TheCodingMachine\GraphQLite\Annotations\Query; /** * Class MyPresenter * * @package App\Presenters */ final class MyPresenter { /** * GraphQL request example: * { * echo(name: "World") * } * outputs -> "Hello World" */ #[Query] public function echo(string $name): string { return 'Hello '. $name; } }
Want to modify the Schema Factory instance?
Use the already predefined class attributes:
#[Authentication]
-> class must implementTheCodingMachine\GraphQLite\Security\AuthenticationServiceInterface
#[Authorization]
-> class must implementTheCodingMachine\GraphQLite\Security\AuthorizationServiceInterface
#[Middleware(Middleware::FIELD)]
-> class must implementTheCodingMachine\GraphQLite\Middlewares\FieldMiddlewareInterface
#[Middleware(Middleware::PARAMETER)]
-> class must implementTheCodingMachine\GraphQLite\Middlewares\ParameterMiddlewareInterface
Or use a custom implementation of Maxa\Ondrej\Nette\GraphQL\DI\SchemaFactoryDecoratorService
and add class attribute #[FactoryDecorator]
.
GraphQLite documentation