@@ -41,9 +41,33 @@ Types can be define 3 different ways:
41
41
You can also declare PHP types (any subclass of ` GraphQL\Type\Definition\Type`)
42
42
in `src/*Bundle/GraphQL` or `app/GraphQL`
43
43
they will be auto discover (thanks to auto mapping). Auto map classes are accessible by FQCN
44
- (example : ` AppBunble\G raphQL\T ype\D ateTimeType` ), you can also alias type adding
45
- a public static function `getAliases `
44
+ (example : ` AppBunble\G raphQL\T ype\D ateTimeType` ), you can also alias a type by
45
+ implementing `Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface `
46
46
that returns an array of aliases.
47
+
48
+ here an example :
49
+
50
+ ` ` ` php
51
+ <?php
52
+
53
+ namespace App\G raphQL\T ype;
54
+
55
+ use Overblog\G raphQLBundle\D efinition\R esolver\A liasedInterface;
56
+ use GraphQL\T ype\D efinition\S calarType;
57
+
58
+ class DateTimeType extends ScalarType implements AliasedInterface
59
+ {
60
+ /**
61
+ * {@inheritdoc}
62
+ */
63
+ public static function getAliases()
64
+ {
65
+ return ['DateTime', 'Date'];
66
+ }
67
+ // ...
68
+ }
69
+ ` ` `
70
+
47
71
You can also define custom dirs using config :
48
72
` ` ` yaml
49
73
overblog_graphql:
@@ -53,13 +77,33 @@ Types can be define 3 different ways:
53
77
- "%kernel.root_dir%/src/*Bundle/CustomDir"
54
78
- "%kernel.root_dir%/src/AppBundle/{foo,bar}"
55
79
` ` `
56
- To disable auto mapping :
80
+
81
+ If using Symfony 3.3+ disabling auto mapping can be a solution to leave place to native
82
+ DI `autoconfigure` :
83
+
57
84
` ` ` yaml
58
85
overblog_graphql:
59
86
definitions:
60
87
auto_mapping: false
61
88
` ` `
62
89
90
+ Here an example of how this can be done with DI `autoconfigure` :
91
+
92
+ ` ` ` yaml
93
+ services:
94
+ _instanceof:
95
+ GraphQL\T ype\D efinition\T ype:
96
+ tags: ['overblog_graphql.type']
97
+
98
+ App\T ype\:
99
+ resource: '../src/Type'
100
+ ` ` `
101
+
102
+ **Note:**
103
+ * Types are lazy loaded so when using Symfony DI `autoconfigure` or this bundle auto mapping, the
104
+ only access to type is FQCN (or aliases if implements the aliases interface).
105
+ * When using FQCN in yaml definition, backslash must be correctly quotes,
106
+
63
107
3. **The service way**
64
108
65
109
Creating a service tagged `overblog_graphql.type`
0 commit comments