Skip to content

Commit

Permalink
fix(package/gqty): allow resolve to return null (#1992)
Browse files Browse the repository at this point in the history
* fix(package/gqty): allow resolve to return null

* feat(test-utils): new mocked client for testing

* fix(package/react): test errors
  • Loading branch information
vicary authored Aug 13, 2024
1 parent 2338adb commit c222005
Show file tree
Hide file tree
Showing 24 changed files with 1,311 additions and 148 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-crabs-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'test-utils': minor
---

A new mocked test client for testing
5 changes: 5 additions & 0 deletions .changeset/hungry-sheep-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gqty': patch
---

Allow `resolve` to return `null`
64 changes: 64 additions & 0 deletions internal/test-utils/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// esbuild --bundle --minify --sourcemap --outdir=dist src/index.ts

import { build, type BuildOptions } from 'esbuild';
import fs from 'node:fs';
import path from 'node:path';
import tsc from 'typescript';
import packageJson from './package.json';

fs.rmSync('dist/', { force: true, recursive: true });

const baseOptions: BuildOptions = {
bundle: true,
entryPoints: ['src/index.ts'],
external: Object.keys({
...packageJson.dependencies,
...packageJson.devDependencies,
...packageJson.peerDependencies,
}),
minify: true,
platform: 'node',
target: 'es2020',
};

// Build ESM module
build({
...baseOptions,
format: 'esm',
outfile: 'dist/index.mjs',
});

// Build CommonJS module
build({
...baseOptions,
format: 'cjs',
outfile: 'dist/index.cjs',
});

// tsc --emitDeclarationOnly
tsc
.createProgram(['src/index.ts'], {
baseUrl: '.',
declaration: true,
emitDeclarationOnly: true,
forceConsistentCasingInFileNames: true,
noFallthroughCasesInSwitch: true,
noImplicitReturns: true,
noUnusedLocals: true,
noUnusedParameters: true,
outDir: 'dist',
rootDir: 'src',
skipLibCheck: true,
strict: true,
target: tsc.ScriptTarget.ESNext,
verbatimModuleSyntax: true,
})
.emit(undefined, undefined, undefined, true);

// Copy project files
for (const file of ['../../LICENSE', '../../README.md', 'package.json']) {
fs.copyFileSync(
path.normalize(path.join(import.meta.dirname ?? '.', file)),
path.join('dist', path.basename(file))
);
}
2 changes: 1 addition & 1 deletion internal/test-utils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const defaultConfig = {
url: 'http://localhost',
},
testPathIgnorePatterns: ['/node_modules/', '/test/generated'],
collectCoverage: true,
collectCoverage: !!process.env.CI,
collectCoverageFrom: ['./src/**/*.ts', './src/**/*.tsx', '!**/*.d.ts'],
testTimeout: 10000,
watchPlugins: [
Expand Down
40 changes: 23 additions & 17 deletions internal/test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "test-utils",
"version": "0.1.0",
"private": true,
"license": "MIT",
"author": "PabloSzx <[email protected]>",
"maintainers": [
Expand All @@ -10,42 +10,54 @@
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./*": {
"require": "./dist/*.js",
"import": "./dist/*.mjs"
"import": "./dist/*.mjs",
"types": "./dist/*.d.ts"
},
"./jest.config.js": "./jest.config.js"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "src/index.d.ts",
"bin": {
"jest-test": "bin/jest-test.js"
},
"scripts": {
"build": "bob-ts -i src -f interop",
"build": "tsx build.ts",
"prepare": "pnpm build",
"start": "nodemon --exec \"concurrently pnpm:build tsc\" -w src/index.ts",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config local.jest.config.js"
},
"types": "src/index.ts",
"dependencies": {
"@graphql-ez/fastify": "^0.12.1",
"@graphql-ez/fastify-testing": "^0.4.1",
"@graphql-ez/plugin-codegen": "^0.8.1",
"@graphql-ez/plugin-schema": "^0.9.1",
"@graphql-tools/executor-http": "^1.0.9",
"@rollup/plugin-babel": "^6.0.4",
"@types/jest": "^29.5.12",
"cross-env": "^7.0.3",
"fastify": "^4.28.1",
"gqty": "workspace:^",
"graphql": "^16.9.0",
"graphql-ez": "^0.16.1",
"graphql-scalars": "^1.23.0",
"graphql-ws": "^5.16.0",
"graphql-yoga": "^5.4.0",
"jest": "^29.7.0",
"jest-watch-typeahead": "^2.2.2",
"randomstring": "^1.3.0",
"wait-for-expect": "^3.0.2"
},
"devDependencies": {
"@graphql-ez/plugin-websockets": "^0.11.3",
"@jest/types": "^29.6.3",
"@types/node": "^20.14.15",
"esbuild": "^0.23.0",
"typescript": "^5.5.4"
},
"peerDependencies": {
"graphql": "*"
},
Expand All @@ -54,15 +66,9 @@
"optional": true
}
},
"devDependencies": {
"@graphql-ez/plugin-websockets": "^0.11.3",
"@jest/types": "^29.6.3",
"@types/node": "^20.14.15",
"@types/randomstring": "^1.3.0",
"bob-esbuild-cli": "^4.0.0",
"bob-ts": "^4.1.1",
"concurrently": "^8.2.2",
"esbuild": "^0.23.0",
"tslib": "^2.6.3"
"gqty": {
"scalarTypes": {
"Date": "string"
}
}
}
Loading

0 comments on commit c222005

Please sign in to comment.