Skip to content

Commit c6b1ee2

Browse files
committed
Fix
1 parent 28e4510 commit c6b1ee2

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

packages/jest-transform/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"import": "./dist/*.mjs"
2222
}
2323
},
24+
"typings": "dist/index.d.ts",
25+
"typescript": {
26+
"definition": "dist/index.d.ts"
27+
},
2428
"peerDependencies": {
2529
"graphql": "^14.0.0 || ^15.0.0"
2630
},

packages/jest-transform/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import loader, { Options } from '@graphql-tools/webpack-loader';
2-
import { Transformer } from '@jest/transform';
1+
import loader from '@graphql-tools/webpack-loader';
2+
import { SyncTransformer, TransformOptions } from '@jest/transform';
33
import { Config } from '@jest/types';
44

5-
export interface GraphQLGlobalOptions extends Options {}
5+
export type GraphQLGlobalOptions = ThisParameterType<typeof loader>['query'];
66

77
declare module '@jest/types' {
88
namespace Config {
@@ -12,9 +12,9 @@ declare module '@jest/types' {
1212
}
1313
}
1414

15-
class GraphQLTransformer implements Transformer {
16-
process(input: string, _filePath: Config.Path, jestConfig: Config.ProjectConfig): string {
17-
const config = jestConfig.globals?.['graphql'] || {};
15+
class GraphQLTransformer implements SyncTransformer {
16+
process(input: string, _filePath: Config.Path, jestConfig: TransformOptions): string {
17+
const config = jestConfig.config.globals?.['graphql'] || {};
1818
// call directly the webpack loader with a mocked context
1919
// as the loader leverages `this.cacheable()`
2020
return loader.call(

packages/webpack-loader/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function isSDL(doc: DocumentNode) {
88
return !doc.definitions.some(def => isExecutableDefinitionNode(def));
99
}
1010

11-
export interface Options {
11+
interface Options {
1212
noDescription?: boolean;
1313
noEmptyNodes?: boolean;
1414
noLoc?: boolean;
@@ -41,7 +41,7 @@ function expandImports(source: string, options: Options) {
4141
return outputCode;
4242
}
4343

44-
export default function graphqlLoader(source: string) {
44+
export default function graphqlLoader(this: { query: Options; cacheable: VoidFunction }, source: string) {
4545
this.cacheable();
4646
const options: Options = this.query || {};
4747
let doc = parseDocument(source);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"skipLibCheck": true,
2626

2727
"paths": {
28-
"@graphql-tools/*-loader": ["packages/loaders/*/src/index.ts"],
28+
"@graphql-tools/*-loader": ["packages/loaders/*/src/index.ts", "packages/*-loader/src/index.ts"],
2929
"@graphql-tools/*": ["packages/*/src/index.ts"]
3030
}
3131
},

0 commit comments

Comments
 (0)