@@ -82,16 +82,15 @@ protected function registerConnection(
8282 $ connectionTypeName = "{$ fieldTypeName }Connection " ;
8383 }
8484
85- $ connectionFieldName = addslashes (ConnectionField::class);
86-
85+ $ connectionFieldClass = addslashes (ConnectionField::class);
8786 $ connectionType = Parser::objectTypeDefinition (/** @lang GraphQL */ <<<GRAPHQL
8887 "A paginated list of {$ fieldTypeName } edges."
8988 type {$ connectionTypeName } {
9089 "Pagination information about the list of edges."
91- {$ paginationType ->infoFieldName ()}: PageInfo! @field(resolver: " {$ connectionFieldName }@pageInfoResolver")
90+ {$ paginationType ->infoFieldName ()}: PageInfo! @field(resolver: " {$ connectionFieldClass }@pageInfoResolver")
9291
9392 "A list of {$ fieldTypeName } edges."
94- edges: [ {$ connectionEdgeName }!]! @field(resolver: " {$ connectionFieldName }@edgeResolver")
93+ edges: [ {$ connectionEdgeName }!]! @field(resolver: " {$ connectionFieldClass }@edgeResolver")
9594 }
9695GRAPHQL
9796 );
@@ -133,9 +132,7 @@ protected function addPaginationWrapperType(ObjectTypeDefinitionNode $objectType
133132 $ existingType = $ this ->documentAST ->types [$ typeName ] ?? null ;
134133 if ($ existingType !== null ) {
135134 if (! $ existingType instanceof ObjectTypeDefinitionNode) {
136- throw new DefinitionException (
137- "Expected object type for pagination wrapper {$ typeName }, found {$ objectType ->kind } instead. " ,
138- );
135+ throw new DefinitionException ("Expected object type for pagination wrapper {$ typeName }, found {$ objectType ->kind } instead. " );
139136 }
140137
141138 $ objectType = $ existingType ;
@@ -145,7 +142,10 @@ protected function addPaginationWrapperType(ObjectTypeDefinitionNode $objectType
145142 isset ($ this ->modelClass )
146143 && ! ASTHelper::hasDirective ($ objectType , ModelDirective::NAME )
147144 ) {
148- $ objectType ->directives [] = Parser::constDirective (/** @lang GraphQL */ '@model(class: " ' . addslashes ($ this ->modelClass ) . '") ' );
145+ $ modelClassEscaped = addslashes ($ this ->modelClass );
146+ $ objectType ->directives [] = Parser::constDirective (/** @lang GraphQL */ <<<GRAPHQL
147+ @model(class: " {$ modelClassEscaped }")
148+ GRAPHQL );
149149 }
150150
151151 $ this ->documentAST ->setTypeDefinition ($ objectType );
@@ -171,18 +171,16 @@ protected function registerPaginator(
171171 "A list of {$ fieldTypeName } items."
172172 data: [ {$ fieldTypeName }!]! @field(resolver: " {$ paginatorFieldClassName }@dataResolver")
173173 }
174- GRAPHQL
175- );
174+ GRAPHQL );
176175 $ this ->addPaginationWrapperType ($ paginatorType );
177176
178177 $ fieldDefinition ->arguments [] = Parser::inputValueDefinition (
179178 self ::countArgument ($ defaultCount , $ maxCount ),
180179 );
181180 $ fieldDefinition ->arguments [] = Parser::inputValueDefinition (/** @lang GraphQL */ <<<'GRAPHQL'
182- "The offset from which items are returned."
183- page: Int
184- GRAPHQL
185- );
181+ "The offset from which items are returned."
182+ page: Int
183+ GRAPHQL);
186184
187185 $ fieldDefinition ->type = $ this ->paginationResultType ($ paginatorTypeName );
188186 $ parentType ->fields = ASTHelper::mergeUniqueNodeList ($ parentType ->fields , [$ fieldDefinition ], true );
@@ -208,18 +206,16 @@ protected function registerSimplePaginator(
208206 "A list of {$ fieldTypeName } items."
209207 data: [ {$ fieldTypeName }!]! @field(resolver: " {$ paginatorFieldClassName }@dataResolver")
210208 }
211- GRAPHQL
212- );
209+ GRAPHQL );
213210 $ this ->addPaginationWrapperType ($ paginatorType );
214211
215212 $ fieldDefinition ->arguments [] = Parser::inputValueDefinition (
216213 self ::countArgument ($ defaultCount , $ maxCount ),
217214 );
218215 $ fieldDefinition ->arguments [] = Parser::inputValueDefinition (/** @lang GraphQL */ <<<'GRAPHQL'
219- "The offset from which items are returned."
220- page: Int
221- GRAPHQL
222- );
216+ "The offset from which items are returned."
217+ page: Int
218+ GRAPHQL);
223219
224220 $ fieldDefinition ->type = $ this ->paginationResultType ($ paginatorTypeName );
225221 $ parentType ->fields = ASTHelper::mergeUniqueNodeList ($ parentType ->fields , [$ fieldDefinition ], true );
0 commit comments