File tree Expand file tree Collapse file tree
packages/apollo-graphql/src/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -351,6 +351,29 @@ type MutationRoot {
351351 `"Unknown directive \\"@something\\"."`
352352 ) ;
353353 } ) ;
354+
355+ it ( `should preserve directive usages from the schema definition node` , ( ) => {
356+ const schema = buildSchemaFromSDL (
357+ gql `
358+ directive @contact(
359+ name: String!
360+ url: String!
361+ description: String
362+ ) on SCHEMA
363+
364+ schema
365+ @contact(
366+ name: "Contact"
367+ url: "http://example.com/contact"
368+ description: "Testing"
369+ ) {
370+ query: Query
371+ }
372+ `
373+ ) ;
374+ expect ( schema . astNode ?. directives ) . toHaveLength ( 1 ) ;
375+ expect ( schema . astNode ?. directives ! [ 0 ] . name . value ) . toEqual ( "contact" ) ;
376+ } ) ;
354377 } ) ;
355378
356379 describe ( `resolvers` , ( ) => {
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ export function buildSchemaFromSDL(
132132 directiveDefinitions . push ( definition ) ;
133133 } else if ( definition . kind === Kind . SCHEMA_DEFINITION ) {
134134 schemaDefinitions . push ( definition ) ;
135- schemaDirectives . push ( ...( definition . directives ?? [ ] ) )
135+ schemaDirectives . push ( ...( definition . directives ?? [ ] ) ) ;
136136 } else if ( definition . kind === Kind . SCHEMA_EXTENSION ) {
137137 schemaExtensions . push ( definition ) ;
138138 }
You can’t perform that action at this time.
0 commit comments