{"id":14976169,"url":"https://github.com/graphpql/graphpinator-symfony","last_synced_at":"2026-01-28T00:36:19.075Z","repository":{"id":228062372,"uuid":"771615810","full_name":"graphpql/graphpinator-symfony","owner":"graphpql","description":" ⚡🌐⚡ Graphpinator adapters and addons for Symfony framework.","archived":false,"fork":false,"pushed_at":"2026-01-13T12:52:43.000Z","size":159,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T14:25:00.007Z","etag":null,"topics":["api","graphq","graphql-server","symfony"],"latest_commit_sha":null,"homepage":"https://github.com/graphpql","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphpql.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-13T16:17:05.000Z","updated_at":"2026-01-13T12:50:07.000Z","dependencies_parsed_at":"2024-10-11T13:22:07.461Z","dependency_job_id":"ee2aa9a9-22df-4214-be9b-b5d31f6a8e60","html_url":"https://github.com/graphpql/graphpinator-symfony","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"5c9c00fb01b7a3f9a90c5a79f56a5b0fdfea6c8a"},"previous_names":["graphpql/graphpinator-symfony"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/graphpql/graphpinator-symfony","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-symfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-symfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-symfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-symfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphpql","download_url":"https://codeload.github.com/graphpql/graphpinator-symfony/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-symfony/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28829514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","graphq","graphql-server","symfony"],"created_at":"2024-09-24T13:53:25.571Z","updated_at":"2026-01-28T00:36:19.066Z","avatar_url":"https://github.com/graphpql.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graphpinator Symfony \n\n:zap::globe_with_meridians::zap: Graphpinator adapters and addons for Symfony framework.\n\n## Introduction\n\nThis package includes adapters and tools to easily integrate Graphpinator into a Symfony application.\n\n## Installation\n\nInstall package using composer\n\n```composer require graphpql/graphpinator-symfony```\n\n## How to use\n\n### Register a bundle\n\nAdd a bundle entry to the `bundles.php`. Currently the bundle is only used for an access to the twig namespace, so this step can be ommited when the rendering actions will not be used.\n\n```php\nGraphpinator\\Symfony\\GraphpinatorBundle::class =\u003e ['all' =\u003e true],\n```\n\n### Configure dependency injection\n\nAt first we need to configure Symfony to find all our types and tag them, so we can inject them into our type registry.\n\n```yaml\nservices:\n    # Find and register all types into the DI container\n    App\\GraphQL\\Default\\Types\\:\n        resource: '../src/GraphQL/Default/Types'\n        public: true # not needed when you do not have any accessors (see the cyclic dependencies section of this documentation)\n        tags:\n            - 'graphql.default.types'\n    # Find and register all directives into the DI container\n    App\\GraphQL\\Default\\Directives\\:\n        resource: '../src/GraphQL/Default/Directives'\n        tags:\n            - 'graphql.default.directives'\n\n    # Any additional types must be also registred and tagged to become available in the type container\n    Graphpinator\\ExtraTypes\\EmailAddressType:\n        tags:\n            - 'graphql.default.types'\n    Graphpinator\\ExtraTypes\\UrlType:\n        tags:\n            - 'graphql.default.types'\n```\n\nCreate a specific `Container` service for each schema and instruct the DI to inject it with the types and directives using the tags we configured.\n\n```php\n\u003c?php declare(strict_types = 1);\n\nnamespace App\\GraphQL\\Default;\n\nuse Graphpinator\\SimpleContainer;\nuse Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator;\n\nfinal class Container extends SimpleContainer\n{\n    public function __construct(\n        #[TaggedIterator('graphql.default.types')]\n        iterable $types,\n        #[TaggedIterator('graphql.default.directives')]\n        iterable $directives,\n    )\n    {\n        parent::__construct([...$types], [...$directives]);\n    }\n}\n```\n\nCreate a `Schema` service.\n\n```php\n\u003c?php declare(strict_types = 1);\n\nnamespace App\\GraphQL\\Default;\n\nuse App\\GraphQL\\Default\\Container;\nuse Graphpinator\\Typesystem\\Schema as BaseSchema;\n\nfinal class Schema extends BaseSchema\n{\n    public function __construct(Container $container)\n    {\n        parent::__construct($container, $container-\u003egetType('Query'), $container-\u003egetType('Mutation'));\n\n        // You may also configure the schema there\n        $this-\u003esetDescription('My GraphQL API');\n    }\n}\n```\n\nNow the `Schema` is set up and can be used to execute requests on it.\n\n#### Cyclic dependendencies\n\nWhen using abstract types, the cyclic dependencies must be avoided using accessors. In Symfony we need to create a simple service to extract the types from a container.\n\n```php\nfinal class CandidateAccessor\n{\n    public function __construct(private \\Symfony\\Component\\DependencyInjection\\ContainerInterface $container)\n    {\n    }\n\n    public function slideSingle() : SlideSingle\n    {\n        return $this-\u003econtainer-\u003eget(SlideSingle::class);\n    }\n\n    public function slideDouble() : SlideDouble\n    {\n        return $this-\u003econtainer-\u003eget(SlideDouble::class);\n    }\n\n    public function slideTriple() : SlideTriple\n    {\n        return $this-\u003econtainer-\u003eget(SlideTriple::class);\n    }\n}\n\n```\n\nConfigure the accessor service to recieve the DI container as an argument.\n\n```yaml\nservices:\n    SlideAccessor:\n        arguments:\n            $container: '@service_container'\n```\n\nThis service is than injected into the abstract type instead of the concrete types in order to break the dependency cycle.\n\n#### Multiple schemas\n\nSome more sophisticated applications may require to host multiple different GraphQL schemas with different purposes.\nIn the example above we used only the `default` schema, but the same principle can be replicated and applied to any number of schemas within a single application.\n\n### GraphQLController\n\nSimple version of a controller to execute GraphQL API requests against a given schema. It also includes a actions and templates for a schema overview and GraphiQL integration. It can be extended to alter its functionality (for example by overriding the `getEnabledModules` function) or it can serve as an inspiration to include the functionality in your own controllers.\n\nCreate a custom controller in your application which inherits the functionalities from the provided one.\n\n```php\n\u003c?php declare(strict_types = 1);\n\nnamespace App\\Controller\\GraphQL;\n\nuse App\\GraphQL\\Default\\Schema;\nuse Graphpinator\\Symfony\\GraphQLController;\nuse Psr\\Cache\\CacheItemPoolInterface;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\Routing\\Attribute\\Route;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n\n#[Route('/graphql/default', name: 'graphql_default_')]\nfinal class DefaultGraphQlController extends GraphQLController\n{\n    public function __construct(Schema $schema, LoggerInterface $logger, CacheItemPoolInterface $cache, UrlGeneratorInterface $urlGenerator)\n    {\n        parent::__construct($schema, $logger, $cache, $urlGenerator);\n    }\n}\n\n```\n\nThe base controller handles 5 actions:\n\n- `OPTIONS` `/` to handle CORS\n- `GET` or `POST` `/`  which handles the GraphQL requests\n- `GET` `/schema`  which renders the schema in a GraphQL typesystem language\n- `GET` `/schema.graphql`  which returns the schema in a GraphQL typesystem language as a file attachment\n- `GET` `/ui`  which renders [GraphiQL](https://github.com/graphql/graphiql/tree/main/packages/graphiql#readme), a graphical interface to interact with your schema.\n\n### Adapters\n\n- `\\Graphpinator\\Symfony\\RequestFactory`\n    - Implements `RequestFactory` and enables direct creation of `\\Graphpinator\\Request\\Request` from Symfony HTTP abstraction.\n- `\\Graphpinator\\Symfony\\FileProvider`\n    - Implements `FileProvider` interface needed by `infinityloop-dev/graphpinator-upload` module.\n- `\\Graphpinator\\Symfony\\ConstraintDirectiveAccessor`\n    - Implements `ConstraintDirectiveAccessor` interface needed by `infinityloop-dev/graphpinator-constraint-directives`.\n    - Needs to be manually added to the services.yaml using following configuration:\n      ```yaml\n      services:\n          Graphpinator\\ConstraintDirectives\\ConstraintDirectiveAccessor:\n              class: 'Graphpinator\\Symfony\\ConstraintDirectiveAccessor'\n              arguments:\n                  $container: '@service_container'\n      ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-symfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphpql%2Fgraphpinator-symfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-symfony/lists"}