2525 * See [schema definition language docs](schema-definition-language.md) for details.
2626 *
2727 * @phpstan-import-type TypeConfigDecorator from ASTDefinitionBuilder
28+ * @phpstan-import-type FieldConfigDecorator from ASTDefinitionBuilder
2829 *
2930 * @phpstan-type BuildSchemaOptions array{
3031 * assumeValid?: bool,
@@ -56,6 +57,13 @@ class BuildSchema
5657 */
5758 private $ typeConfigDecorator ;
5859
60+ /**
61+ * @var callable|null
62+ *
63+ * @phpstan-var FieldConfigDecorator|null
64+ */
65+ private $ fieldConfigDecorator ;
66+
5967 /**
6068 * @var array<string, bool>
6169 *
@@ -72,11 +80,13 @@ class BuildSchema
7280 public function __construct (
7381 DocumentNode $ ast ,
7482 ?callable $ typeConfigDecorator = null ,
75- array $ options = []
83+ array $ options = [],
84+ ?callable $ fieldConfigDecorator = null
7685 ) {
7786 $ this ->ast = $ ast ;
7887 $ this ->typeConfigDecorator = $ typeConfigDecorator ;
7988 $ this ->options = $ options ;
89+ $ this ->fieldConfigDecorator = $ fieldConfigDecorator ;
8090 }
8191
8292 /**
@@ -86,6 +96,7 @@ public function __construct(
8696 * @param DocumentNode|Source|string $source
8797 *
8898 * @phpstan-param TypeConfigDecorator|null $typeConfigDecorator
99+ * @phpstan-param FieldConfigDecorator|null $fieldConfigDecorator
89100 *
90101 * @param array<string, bool> $options
91102 *
@@ -102,13 +113,14 @@ public function __construct(
102113 public static function build (
103114 $ source ,
104115 ?callable $ typeConfigDecorator = null ,
105- array $ options = []
116+ array $ options = [],
117+ ?callable $ fieldConfigDecorator = null
106118 ): Schema {
107119 $ doc = $ source instanceof DocumentNode
108120 ? $ source
109121 : Parser::parse ($ source );
110122
111- return self ::buildAST ($ doc , $ typeConfigDecorator , $ options );
123+ return self ::buildAST ($ doc , $ typeConfigDecorator , $ options, $ fieldConfigDecorator );
112124 }
113125
114126 /**
@@ -120,6 +132,7 @@ public static function build(
120132 * has no resolve methods, so execution will use default resolvers.
121133 *
122134 * @phpstan-param TypeConfigDecorator|null $typeConfigDecorator
135+ * @phpstan-param FieldConfigDecorator|null $fieldConfigDecorator
123136 *
124137 * @param array<string, bool> $options
125138 *
@@ -135,9 +148,10 @@ public static function build(
135148 public static function buildAST (
136149 DocumentNode $ ast ,
137150 ?callable $ typeConfigDecorator = null ,
138- array $ options = []
151+ array $ options = [],
152+ ?callable $ fieldConfigDecorator = null
139153 ): Schema {
140- return (new self ($ ast , $ typeConfigDecorator , $ options ))->buildSchema ();
154+ return (new self ($ ast , $ typeConfigDecorator , $ options, $ fieldConfigDecorator ))->buildSchema ();
141155 }
142156
143157 /**
@@ -200,7 +214,8 @@ public function buildSchema(): Schema
200214 static function (string $ typeName ): Type {
201215 throw self ::unknownType ($ typeName );
202216 },
203- $ this ->typeConfigDecorator
217+ $ this ->typeConfigDecorator ,
218+ $ this ->fieldConfigDecorator
204219 );
205220
206221 $ directives = \array_map (
0 commit comments