{"id":15080673,"url":"https://github.com/graphpql/graphpinator-nette","last_synced_at":"2025-08-12T13:04:33.405Z","repository":{"id":50094692,"uuid":"304912471","full_name":"graphpql/graphpinator-nette","owner":"graphpql","description":":zap::globe_with_meridians::zap: Graphpinator adapters and addons for Nette framework.","archived":false,"fork":false,"pushed_at":"2025-07-07T02:55:01.000Z","size":357,"stargazers_count":4,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-04T22:36:18.418Z","etag":null,"topics":["graphql","graphql-php","nette","php"],"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":"CODE_OF_CONDUCT.md","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}},"created_at":"2020-10-17T15:47:54.000Z","updated_at":"2025-07-02T20:38:13.000Z","dependencies_parsed_at":"2023-11-07T02:10:27.207Z","dependency_job_id":"c51d18c2-48b9-44fc-86fd-af44fbd3e312","html_url":"https://github.com/graphpql/graphpinator-nette","commit_stats":null,"previous_names":["graphpql/graphpinator-nette","infinityloop-dev/graphpinator-nette"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/graphpql/graphpinator-nette","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-nette","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-nette/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-nette/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-nette/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphpql","download_url":"https://codeload.github.com/graphpql/graphpinator-nette/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-nette/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270065422,"owners_count":24520946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["graphql","graphql-php","nette","php"],"created_at":"2024-09-25T05:05:13.318Z","updated_at":"2025-08-12T13:04:33.374Z","avatar_url":"https://github.com/graphpql.png","language":"PHP","readme":"# Graphpinator Nette [![PHP](https://github.com/infinityloop-dev/graphpinator-nette/workflows/PHP/badge.svg?branch=master)](https://github.com/infinityloop-dev/graphpinator-nette/actions?query=workflow%3APHP) [![codecov](https://codecov.io/gh/infinityloop-dev/graphpinator-nette/branch/master/graph/badge.svg)](https://codecov.io/gh/infinityloop-dev/graphpinator-nette)\n\n:zap::globe_with_meridians::zap: Graphpinator adapters and addons for Nette framework.\n\n## Introduction\n\nThis package includes adapters and tools to easily integrate Graphpinator into a Nette application.\n\n## Installation\n\nInstall package using composer\n\n```composer require infinityloop-dev/graphpinator-nette```\n\n## How to use\n\n### ApiPresenter\n\nSimple version of a presenter to execute GraphQL API requests against a given schema. 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 presenters.\n\nPresenter is enabled by creating a route:\n\n```php\n$router[] = new Route('/', [\n    'module' =\u003e 'Graphpinator',\n    'presenter' =\u003e 'Api',\n]);\n```\n\nYou also need to register the module with presenters to map to the correct namespace.\n\n```neon\napplication:\n    mapping:\n        Graphpinator: 'Graphpinator\\Nette\\*Presenter'\n```\n\nThere needs to be a `Schema` and a `NetteCache` service available in your DI container so that it can be injected into the presenter.\n\n```neon\n# Automatically find and register all types and directives located in `GraphQl` namespace as services\nsearch:\n    graphql:\n        in: '%appDir%/GraphQL'\n        extends:\n            - Graphpinator\\Typesystem\\Contract\\NamedType\n            - Graphpinator\\Typesystem\\Contract\\Directive\nservices:\n    # Register a NetteCache adapter\n    - Graphpinator\\Nette\\NetteCache\n\n    # The SimpleContainer is a container of GraphQL types\n    # It is automatically injected by all types and directives as Nette automatically detects a typehint in SimpleContainers contructor\n    - Graphpinator\\SimpleContainer\n\n    # Any additional types must be also registred to become available in the type container\n    - Graphpinator\\ExtraTypes\\EmailAddressType\n    - Graphpinator\\ExtraTypes\\PhoneNumberType\n\n    # Register a Schema\n    - Graphpinator\\Typesystem\\Schema(\n        @Graphpinator\\SimpleContainer, # Container of types\n        @App\\GraphQL\\Query, # Query type\n        null, # Mutation type\n        null # Subscription type\n    )\n\n   # Alternativelly you may use the named service and add a setup to the Schema service\n   schema.public:\n        factory: Graphpinator\\Typesystem\\Schema(\n            @Graphpinator\\SimpleContainer,\n            @App\\GraphQL\\Query,\n            @App\\GraphQL\\Mutation,\n            null\n        )\n        setup:\n            - setDescription(\"\"\"\n            My GraphQL API\n            \"\"\")\n```\n\n### SchemaPresenter\n\nSchema presenter contains two actions.\n- actionHtml, which renders HTML page\n- actionFile, which renders text file - file is sent to browser as an attachment, which tells the browser to show the download prompt\n\nAction can be enabled using Router, here is the example which enables the HTML action on the `/schema.graphql` path.\n\n```php\n$router[] = new Route('/schema.graphql',\n    'module' =\u003e 'Graphpinator',\n    'presenter' =\u003e 'Schema',         \n    'action' =\u003e 'html',\n]);\n```\n\n### GraphiQLPresenter\n\nPresenter which include [GraphiQL](https://github.com/graphql/graphiql/tree/main/packages/graphiql#readme), a graphical interface to interact with your schema.\n\nPresenter is enabled by creating a route:\n\n```php\n$router[] = new Route('/graphiql',\n    'module' =\u003e 'Graphpinator',\n    'presenter' =\u003e 'GraphiQl',         \n    'action' =\u003e 'default',\n]);\n```\n\nIt is also required to pass a location of your API endpoint, to which GraphiQL will connect to.\n\n```neon\nservices:\n    - Graphpinator\\Nette\\GraphiQlPresenter(':Api:Graphql:default')\n```\n\n### Cyclic dependendencies\n\nWhen using abstract types, the cyclic dependencies must be avoided using accessors. Nette makes it easy by automatically providing implementation for a accessor interface using a simple DI condifuration.\n    \n```php\ninterface SlideAccessor\n{\n    public function getSlideSingle() : SlideSingle;\n\n    public function getSlideDouble() : SlideDouble;\n\n    public function getSlideTriple() : SlideTriple;\n}\n```\n\n```neon\nservices:\n    - SlideAccessor(\n        slideSingle: @SlideSingle\n        slideDouble: @SlideDouble\n        slideTriple: @SlideTriple\n    )\n```\n\nThis interface 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 order to do this, we need to use a different approach when configuring the DI.\n\n```neon\n# Search and register all the types in directives in a given namespace - and also append a tag to those services\nsearch:\n    graphqlPublicTypes:\n        in: '%appDir%/GraphQL/Public'\n        extends:\n            - Graphpinator\\Typesystem\\Contract\\NamedType\n        tags:\n            - graphql.public.types\n    graphqlPublicDirectives:\n        in: '%appDir%/GraphQL/Public'\n        extends:\n            - Graphpinator\\Typesystem\\Contract\\Directive\n        tags:\n            - graphql.public.directives\nservices:\n    # Register a container and inject services with a tag\n    publicContainer:\n        factory: Graphpinator\\SimpleContainer(\n            tagged( graphql.public.types )\n            tagged( graphql.public.directives )\n        )\n    # Register a Schema using a container with the correct set of types\n    - App\\GraphQL\\Public\\Schema(@publicContainer)\n```\n\nIt is reccomended to use a separate class for each `Schema` so that it can be easily registered as a separate service and injected into a presenter.\n\n```php\n\u003c?php declare(strict_types = 1);\n\nnamespace App\\GraphQL\\Public;\n\nfinal class Schema extends \\Graphpinator\\Typesystem\\Schema\n{\n    public function __construct(\\Graphpiantor\\SimpleContainer $container)\n    {\n        parent::__construct($container, $container-\u003egetType('Query'), $container-\u003egetType('Mutation'));\n\n        $this-\u003esetDescription('My GraphQL API');\n    }\n}\n```\n\n### Adapters\n\n- `\\Graphpinator\\Nette\\TracyLogger`\n    - Implements logger interface for logging in `\\Graphpinator\\Graphpinator`.\n- `\\Graphpinator\\Nette\\NetteRequestFactory`\n    - Implements `RequestFactory` and enables direct creation of `\\Graphpinator\\Request\\Request` from Nette HTTP abstraction.\n- `\\Graphpinator\\Nette\\FileProvider`\n    - Implements `FileProvider` interface needed by `infinityloop-dev/graphpinator-upload` module.\n- `\\Graphpinator\\Nette\\NetteCache`\n    - Adapter from Nette Caching to Psr CacheInterface needed by `infinityloop-dev/graphpinator-persisted-queries` module.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-nette","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphpql%2Fgraphpinator-nette","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-nette/lists"}