Types can be define 3 different ways:
-
The configuration way
Creating this file extension .types.yml or .types.xml in
src/*Bundle/Resources/config/graphql
orapp/config/graphql
. See the different possible types:You can also define custom dirs using config:
overblog_graphql: definitions: mappings: # auto_discover: false # to disable bundles and root dir auto discover types: - type: yaml # or xml or null dir: "%kernel.root_dir%/.../mapping" # sub directories are also searched # suffix: .types # use to change default file suffix
-
The PHP way
You can also declare PHP types (any subclass of
GraphQL\Type\Definition\Type
) insrc/*Bundle/GraphQL
orapp/GraphQL
they will be auto discover (thanks to auto mapping). Auto map classes are accessible by FQCN (example:AppBunble\GraphQL\Type\DateTimeType
), you can also alias type adding a public static functiongetAliases
that returns an array of aliases. You can also define custom dirs using config:overblog_graphql: definitions: auto_mapping: directories: - "%kernel.root_dir%/src/*Bundle/CustomDir" - "%kernel.root_dir%/src/AppBundle/{foo,bar}"
To disable auto mapping:
overblog_graphql: definitions: auto_mapping: false
-
The service way
Creating a service tagged
overblog_graphql.type
services: AppBundle\GraphQL\Type\DateTime: # only for sf < 3.3 #class: AppBundle\GraphQL\Type\DateTime tags: - { name: overblog_graphql.type, alias: DateTime }