25
25
* See [schema definition language docs](schema-definition-language.md) for details.
26
26
*
27
27
* @phpstan-import-type TypeConfigDecorator from ASTDefinitionBuilder
28
+ * @phpstan-import-type FieldConfigDecorator from ASTDefinitionBuilder
28
29
*
29
30
* @phpstan-type BuildSchemaOptions array{
30
31
* assumeValid?: bool,
@@ -56,6 +57,13 @@ class BuildSchema
56
57
*/
57
58
private $ typeConfigDecorator ;
58
59
60
+ /**
61
+ * @var callable|null
62
+ *
63
+ * @phpstan-var FieldConfigDecorator|null
64
+ */
65
+ private $ fieldConfigDecorator ;
66
+
59
67
/**
60
68
* @var array<string, bool>
61
69
*
@@ -72,11 +80,13 @@ class BuildSchema
72
80
public function __construct (
73
81
DocumentNode $ ast ,
74
82
?callable $ typeConfigDecorator = null ,
75
- array $ options = []
83
+ array $ options = [],
84
+ ?callable $ fieldConfigDecorator = null
76
85
) {
77
86
$ this ->ast = $ ast ;
78
87
$ this ->typeConfigDecorator = $ typeConfigDecorator ;
79
88
$ this ->options = $ options ;
89
+ $ this ->fieldConfigDecorator = $ fieldConfigDecorator ;
80
90
}
81
91
82
92
/**
@@ -86,6 +96,7 @@ public function __construct(
86
96
* @param DocumentNode|Source|string $source
87
97
*
88
98
* @phpstan-param TypeConfigDecorator|null $typeConfigDecorator
99
+ * @phpstan-param FieldConfigDecorator|null $fieldConfigDecorator
89
100
*
90
101
* @param array<string, bool> $options
91
102
*
@@ -102,13 +113,14 @@ public function __construct(
102
113
public static function build (
103
114
$ source ,
104
115
?callable $ typeConfigDecorator = null ,
105
- array $ options = []
116
+ array $ options = [],
117
+ ?callable $ fieldConfigDecorator = null
106
118
): Schema {
107
119
$ doc = $ source instanceof DocumentNode
108
120
? $ source
109
121
: Parser::parse ($ source );
110
122
111
- return self ::buildAST ($ doc , $ typeConfigDecorator , $ options );
123
+ return self ::buildAST ($ doc , $ typeConfigDecorator , $ options, $ fieldConfigDecorator );
112
124
}
113
125
114
126
/**
@@ -120,6 +132,7 @@ public static function build(
120
132
* has no resolve methods, so execution will use default resolvers.
121
133
*
122
134
* @phpstan-param TypeConfigDecorator|null $typeConfigDecorator
135
+ * @phpstan-param FieldConfigDecorator|null $fieldConfigDecorator
123
136
*
124
137
* @param array<string, bool> $options
125
138
*
@@ -135,9 +148,10 @@ public static function build(
135
148
public static function buildAST (
136
149
DocumentNode $ ast ,
137
150
?callable $ typeConfigDecorator = null ,
138
- array $ options = []
151
+ array $ options = [],
152
+ ?callable $ fieldConfigDecorator = null
139
153
): Schema {
140
- return (new self ($ ast , $ typeConfigDecorator , $ options ))->buildSchema ();
154
+ return (new self ($ ast , $ typeConfigDecorator , $ options, $ fieldConfigDecorator ))->buildSchema ();
141
155
}
142
156
143
157
/**
@@ -200,7 +214,8 @@ public function buildSchema(): Schema
200
214
static function (string $ typeName ): Type {
201
215
throw self ::unknownType ($ typeName );
202
216
},
203
- $ this ->typeConfigDecorator
217
+ $ this ->typeConfigDecorator ,
218
+ $ this ->fieldConfigDecorator
204
219
);
205
220
206
221
$ directives = \array_map (
0 commit comments