Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/railt/symfony-bundle
📦 The Symfony Framework Bundle for Railt.
https://github.com/railt/symfony-bundle
bundle graphql integration package railt symfony symfony-bundle
Last synced: about 1 month ago
JSON representation
📦 The Symfony Framework Bundle for Railt.
- Host: GitHub
- URL: https://github.com/railt/symfony-bundle
- Owner: railt
- License: mit
- Created: 2017-09-13T21:42:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T23:25:51.000Z (about 1 year ago)
- Last Synced: 2024-04-18T06:23:19.583Z (8 months ago)
- Topics: bundle, graphql, integration, package, railt, symfony, symfony-bundle
- Language: PHP
- Homepage: https://railt.org
- Size: 65.4 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
This Symfony bundle provides integration of [GraphQL](https://facebook.github.io/graphql/)
using [Railt GraphQL](https://github.com/railt/railt).## Requirements
- php: `^8.1`
- symfony: `^5.4|^6.0`
- railt/railt: `^2.0`## Installation
Library is available as composer repository and can be installed using the
following command in a root of your project.```shell
$ composer require railt/symfony-bundle
```Then add bundle into the registered `config/bundles.php` list:
```php
['all' => true],
];```
## Configuration
The fastest way to get started is to create the following configuration file
in `config/packages/railt.yaml`.```yaml
railt:
endpoints:
default:
route: /graphql
schema: '%kernel.project_dir%/resources/schema.graphqls'playground:
default:
endpoint: default
route: /graphiql
```And `schema.graphqls` files inside the `resources` directory in root of your
project with the following content:
```graphql
schema {
query: Query
}type Query {
hello: String @route(action: "App\Controller\ExampleController")
}
```Then create the following controller:
```php
:
# option: value-1
# :
# option: value-2
# ```
#
compilers:
default:
#
# Reference to the PSR-6 or PSR-16 cache service.
#
# default: null
#
cache: 'cache.app'#
# Compiler's specification version.
#
# Should be one of:
# - "railt" - Modern extended version of specification.
# - "draft" - See https://spec.graphql.org/draft/
# - "october-2021" - See https://spec.graphql.org/October2021/
# - "june-2018" - See https://spec.graphql.org/June2018/
# - "october-2016" - See https://spec.graphql.org/October2016/
# - "april-2016" - See https://spec.graphql.org/April2016/
# - "october-2015" - See https://spec.graphql.org/October2015/
# - "july-2015" - See https://spec.graphql.org/July2015/
#
# default: "railt"
#
spec: railt#
# Reference to predefined types service.
#
# Should be instance of `Railt\TypeSystem\DictionaryInterface`.
#
# default: null
#
types: null#
# Autogenerated root types stubs.
#
generate:
#
# Generated root object type name for queries.
#
# default: "Query"
#
query: Query#
# Generated root object type name for mutations.
#
# default: null
#
mutation: null#
# Generated root object type name for subscriptions.
#
# default: null
#
subscription: null#
# Auto casting types compiler's options.
#
cast:
#
# Allow to cast integer values as floats.
#
# ```
# input Example {
#
# "Allow Int(1) as default of Float"
# inCaseOfEnabled(arg: Float = 1): Any
#
# "Allow only Float(1.0) as default of Float"
# inCaseOfDisabled(arg: Float = 1.0): Any
#
# }
# ```
#
# default: true
#
int_to_float: true#
# Allow to cast scalar values as strings.
#
# ```
# input Example {
#
# "Allow Float(1.0) as default of String"
# inCaseOfEnabled(arg: String = 1.0): Any
#
# "Allow only String("1.0") as default of String"
# inCaseOfDisabled(arg: String = "1.0"): Any
#
# }
# ```
#
# default: true
#
scalar_to_string: true#
# Default values extraction logic.
#
extract:
#
# Allow to extract nullable types as default values.
#
# ```
# input Example {
#
# "Allow nullables as default values"
# inCaseOfEnabled(arg: String): Any
#
# "In case of disabled the default value must be defined explicitly"
# inCaseOfDisabled(arg: String = null): Any
#
# }
# ```
#
# default: true
#
nullable: true#
# Allow to extract list types as default values.
#
# ```
# input Example {
#
# "Allow lists as default values"
# inCaseOfEnabled(arg: [String]!): Any
#
# "In case of disabled the default value must be defined explicitly"
# inCaseOfDisabled(arg: [String]! = []): Any
#
# }
# ```
#
# default: true
#
list: true#
# List of directories from which GraphQL files should be loaded.
#
# In the case that a "%kernel.project_dir%/resources" directory is
# specified, then in case when assembling the schema, type "Example" is
# required (for example: `field(arg: Example): String`) then
# "%kernel.project_dir%/resources/Example.graphqls" or
# "%kernel.project_dir%/resources/Example.graphql" will be loaded
# (if exists).
#
# default: []
#
autoload:
- '%kernel.project_dir%/resources'#
# List of public GraphQL endpoints.
#
# ```
# endpoints:
# :
# option: value-1
# :
# option: value-2
# ```
#
endpoints:
default:
#
# URI pathname to the GraphQL endpoint.
#
# required
#
route: /graphql#
# Pathname to the GraphQL schema file.
#
# required
#
schema: '%kernel.project_dir%/resources/schema.graphqls'#
# List of variables passed to the schema file.
#
# You can use these values inside the schema file:
#
# ```
# variables:
# exampleController: "Path\To\ExampleController"
# ```
#
# ```
# type UserList {
# get(count: Int! = 100): [User!]
# @route(action: $exampleController)
# }
# ```
#
# default: []
#
variables:
isDebug: '%kernel.debug%'#
# Reference to defined compiler (from "compilers" section) name or
# reference to Symfony's DI service.
#
# default: null
#
compiler: default#
# List of GraphQL middleware.
#
# Should be instance of `Railt\Contracts\Http\Middleware\MiddlewareInterface`.
#
# default: []
#
middleware: []#
# List of Railt GraphQL extensions (plugins).
#
# Should be instance of `Railt\Foundation\Extension\ExtensionInterface`.
#
# default: []
#
extensions:
- Railt\Extension\Router\RouterExtension
- Railt\Extension\DefaultValue\DefaultValueExtension#
# List of GraphQL playground (GraphiQL) endpoints.
# See: https://github.com/graphql/graphiql
#
# ```
# playground:
# :
# option: value-1
# :
# option: value-2
# ```
#
playground:
default:
#
# Reference to "endpoints" section for which this
# playground will be used.
#
# required
#
endpoint: default#
# URI pathname of playground.
#
# required
#
route: /graphiql#
# List of additional optional headers that be used for each request.
#
# default: []
#
headers:
X-Api-Playground: GraphiQL
```