-
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathplugin.ts
More file actions
19 lines (16 loc) · 623 Bytes
/
plugin.ts
File metadata and controls
19 lines (16 loc) · 623 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import type { ValidationSchemaPluginConfig } from '../../src/config.js';
import { buildSchema } from 'graphql';
import { plugin } from '../../src/index.js';
export type { ValidationSchemaPluginConfig };
/**
* Build a GraphQL schema from a SDL string and run the plugin with the given
* config. Reduces the boilerplate of `buildSchema` + `plugin(schema, [], config, {})`
* that appears identically in every spec file.
*/
export async function runPlugin(
schemaStr: string,
config: Partial<ValidationSchemaPluginConfig> = {},
) {
const schema = buildSchema(schemaStr);
return plugin(schema, [], config, {});
}