@@ -223,6 +223,97 @@ it("allows adding a non-null list of non-null type", async () => {
223223 expect ( data . randomNumbers ) . toEqual ( [ 5 , 3 , 6 ] ) ;
224224} ) ;
225225
226+ it ( "accepts an array of typedefs" , async ( ) => {
227+ const schema = await buildSchema ( [
228+ ...simplePlugins ,
229+ makeExtendSchemaPlugin ( _build => ( {
230+ typeDefs : [
231+ gql `
232+ extend type Query {
233+ """
234+ A random number generated by a fair dice roll.
235+ """
236+ randomNumber: Int!
237+ }
238+ ` ,
239+ gql `
240+ extend type Query {
241+ """
242+ Gives a list of numbers that were randomly generated by fair dice roll
243+ """
244+ randomNumbers: [Int!]!
245+ }
246+ ` ,
247+ ] ,
248+ resolvers,
249+ } ) ) ,
250+ ] ) ;
251+ expect ( schema ) . toMatchSnapshot ( ) ;
252+ const { data } = await graphql (
253+ schema ,
254+ `
255+ {
256+ randomNumber
257+ randomNumbers
258+ }
259+ `
260+ ) ;
261+ expect ( data . randomNumber ) . toEqual ( 4 ) ;
262+ expect ( data . randomNumbers ) . toEqual ( [ 5 , 3 , 6 ] ) ;
263+ } ) ;
264+
265+ it ( "throws the proper error if an array of typeDefs aren't all DocumentNodes" , ( ) => {
266+ return expect (
267+ buildSchema ( [
268+ ...simplePlugins ,
269+ makeExtendSchemaPlugin ( _build => ( {
270+ typeDefs : [
271+ gql `
272+ extend type Query {
273+ """
274+ A random number generated by a fair dice roll.
275+ """
276+ randomNumber: Int!
277+ }
278+ ` ,
279+ `
280+ extend type Query {
281+ """
282+ Gives a list of numbers that were randomly generated by fair dice roll
283+ """
284+ randomNumbers: [Int!]!
285+ }
286+ ` ,
287+ ] ,
288+ resolvers,
289+ } ) ) ,
290+ ] )
291+ ) . rejects . toMatchInlineSnapshot (
292+ `[Error: The first argument to makeExtendSchemaPlugin must be generated by the \`gql\` helper, or be an array of the same.]`
293+ ) ;
294+ } ) ;
295+
296+ it ( "throws the proper error if a single typeDef isn't a DocumentNode" , ( ) => {
297+ return expect (
298+ buildSchema ( [
299+ ...simplePlugins ,
300+ makeExtendSchemaPlugin ( _build => ( {
301+ typeDefs : `
302+ extend type Query {
303+ """
304+ Gives a list of numbers that were randomly generated by fair dice roll
305+ """
306+ randomNumbers: [Int!]!
307+ }
308+ ` ,
309+ resolvers,
310+ } ) ) ,
311+ ] )
312+ ) . rejects . toMatchInlineSnapshot (
313+ `[Error: The first argument to makeExtendSchemaPlugin must be generated by the \`gql\` helper, or be an array of the same.]`
314+ ) ;
315+ } ) ;
316+
226317it ( "allows adding a field with arguments" , async ( ) => {
227318 const schema = await buildSchema ( [
228319 ...simplePlugins ,
0 commit comments