Skip to content

Commit

Permalink
feat: add more printer options to testSDL method
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Sep 16, 2021
1 parent 7637348 commit d025dda
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Resolver,
ObjectTypeComposerFieldConfigAsObjectDefinition,
inspect,
SchemaPrinterOptions,
} from 'graphql-compose';

const FIELD = 'field';
Expand Down Expand Up @@ -124,16 +125,20 @@ export async function testOperationErrors(
return res?.errors;
}

export function testSDL(opts: {
fc: ObjectTypeComposerFieldConfigAsObjectDefinition<any, any, any> | Resolver;
schemaComposer?: SchemaComposer<any>;
deep?: boolean;
}): string {
export function testSDL(
opts: {
fc: ObjectTypeComposerFieldConfigAsObjectDefinition<any, any, any> | Resolver;
schemaComposer?: SchemaComposer<any>;
deep?: boolean;
} & SchemaPrinterOptions
): string {
const sc = opts.schemaComposer || new SchemaComposer();
sc.Query.setField(FIELD, opts.fc);
sc.buildSchema();
return sc.Query.toSDL({
...opts,
deep: opts.deep ?? true,
omitDescriptions: true,
omitSpecifiedByUrl: true,
});
}

0 comments on commit d025dda

Please sign in to comment.