Skip to content

Commit fdc0a4f

Browse files
authored
add types check github action (#3960)
* add types check github action * add types check github action * add types check github action * rm unneeded prebuild commands for types check
1 parent 92375ce commit fdc0a4f

File tree

25 files changed

+84
-62
lines changed

25 files changed

+84
-62
lines changed

.github/workflows/pr.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ jobs:
3636
name: Build
3737
runs-on: ubuntu-latest
3838
needs: [install]
39-
4039
steps:
4140
- uses: actions/checkout@v4
4241
- uses: actions/setup-node@v4
43-
4442
- id: cache-modules
4543
uses: actions/cache@v4
4644
with:
@@ -109,18 +107,15 @@ jobs:
109107
name: Vitest Unit Tests
110108
runs-on: ubuntu-latest
111109
needs: [build]
112-
113110
steps:
114111
- uses: actions/checkout@v4
115112
- uses: actions/setup-node@v4
116-
117113
- id: cache-modules
118114
uses: actions/cache@v4
119115
with:
120116
path: |
121117
**/node_modules
122118
key: modules-${{ github.sha }}
123-
124119
- uses: actions/cache@v4
125120
with:
126121
key: build-${{ github.sha }}
@@ -131,11 +126,9 @@ jobs:
131126
name: ESLint
132127
runs-on: ubuntu-latest
133128
needs: [build]
134-
135129
steps:
136130
- uses: actions/checkout@v4
137131
- uses: actions/setup-node@v4
138-
139132
- id: cache-modules
140133
uses: actions/cache@v4
141134
with:
@@ -148,11 +141,29 @@ jobs:
148141
path: ${{ env.BUILD-CACHE-LIST }}
149142
- run: yarn eslint
150143

144+
types-check:
145+
name: Types Check
146+
runs-on: ubuntu-latest
147+
needs: [build]
148+
steps:
149+
- uses: actions/checkout@v4
150+
- uses: actions/setup-node@v4
151+
- id: cache-modules
152+
uses: actions/cache@v4
153+
with:
154+
path: |
155+
**/node_modules
156+
key: modules-${{ github.sha }}
157+
- uses: actions/cache@v4
158+
with:
159+
key: build-${{ github.sha }}
160+
path: ${{ env.BUILD-CACHE-LIST }}
161+
- run: yarn types:check
162+
151163
e2e:
152164
name: Cypress
153165
runs-on: ubuntu-latest
154166
needs: [build]
155-
156167
steps:
157168
- uses: actions/checkout@v4
158169
- id: cache-modules

packages/cm6-graphql/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.2.1",
44
"description": "GraphQL language support for CodeMirror 6",
55
"scripts": {
6+
"types:check": "tsc --noEmit",
67
"build": "cm-buildhelper src/index.ts",
78
"prepare": "yarn build",
89
"test": "vitest run"

packages/codemirror-graphql/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"!jest.config.js"
3636
],
3737
"scripts": {
38+
"types:check": "tsc --noEmit",
3839
"build": "node ../../scripts/renameFileExtensions.js './esm/{**,!**/__tests__/}/*.js' . .esm.js",
3940
"test": "vitest"
4041
},

packages/graphiql-plugin-code-exporter/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
".": "./dist/index.js"
2828
},
2929
"scripts": {
30+
"types:check": "tsc --noEmit",
3031
"dev": "vite build --watch",
3132
"build": "vite build && UMD=true vite build",
32-
"prebuild": "yarn types:check",
33-
"postbuild": "cp src/graphiql-code-exporter.d.ts dist/graphiql-code-exporter.d.ts",
34-
"types:check": "tsc --noEmit"
33+
"postbuild": "cp src/graphiql-code-exporter.d.ts dist/graphiql-code-exporter.d.ts"
3534
},
3635
"dependencies": {
3736
"graphiql-code-exporter": "^3.0.3"

packages/graphiql-plugin-doc-explorer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"dist"
3131
],
3232
"scripts": {
33+
"types:check": "tsc --noEmit",
3334
"dev": "vite build --watch",
3435
"build": "vite build",
35-
"test": "vitest",
36-
"types:check": "tsc --noEmit"
36+
"test": "vitest"
3737
},
3838
"peerDependencies": {
3939
"react": "^18 || ^19",

packages/graphiql-plugin-doc-explorer/src/components/__tests__/doc-explorer.spec.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { act, render } from '@testing-library/react';
22
import { GraphQLInt, GraphQLObjectType, GraphQLSchema } from 'graphql';
33
import { FC, useEffect } from 'react';
4-
import type { SchemaContextType } from '@graphiql/react';
54
import {
65
DocExplorerContextProvider,
76
useDocExplorer,
@@ -29,22 +28,17 @@ function makeSchema(fieldName = 'field') {
2928
});
3029
}
3130

32-
const defaultSchemaContext: SchemaContextType = {
33-
fetchError: null,
31+
const defaultSchemaContext = {
32+
...schemaStore.getInitialState(),
3433
introspect() {},
35-
isFetching: false,
3634
schema: makeSchema(),
37-
validationErrors: [],
3835
};
3936

40-
const withErrorSchemaContext: SchemaContextType = {
37+
const withErrorSchemaContext = {
38+
...schemaStore.getInitialState(),
4139
fetchError: 'Error fetching schema',
4240
introspect() {},
43-
isFetching: false,
4441
schema: new GraphQLSchema({ description: 'GraphQL Schema for testing' }),
45-
validationErrors: [],
46-
schemaReference: null!,
47-
setSchemaReference: null!,
4842
};
4943

5044
const DocExplorerWithContext: FC = () => {

packages/graphiql-plugin-doc-explorer/src/context.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ import {
1515
isUnionType,
1616
} from 'graphql';
1717
import { FC, ReactElement, ReactNode, useEffect } from 'react';
18-
import { SchemaContextType, useSchemaStore } from '@graphiql/react';
19-
import { createStore, useStore } from 'zustand';
18+
import {
19+
createBoundedUseStore,
20+
SchemaContextType,
21+
useSchemaStore,
22+
} from '@graphiql/react';
23+
import { createStore } from 'zustand';
2024

2125
export type DocExplorerFieldDef =
2226
| GraphQLField<unknown, unknown>
@@ -150,7 +154,7 @@ export const docExplorerStore = createStore<DocExplorerContextType>(
150154
set(state => {
151155
const oldNavStack = state.explorerNavStack;
152156
if (oldNavStack.length === 1) {
153-
return oldNavStack;
157+
return state;
154158
}
155159
// Spread is needed
156160
const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];
@@ -257,11 +261,7 @@ export const DocExplorerContextProvider: FC<{
257261
return children as ReactElement;
258262
};
259263

260-
function useDocExplorerStore<T>(
261-
selector: (state: DocExplorerContextType) => T,
262-
): T {
263-
return useStore(docExplorerStore, selector);
264-
}
264+
const useDocExplorerStore = createBoundedUseStore(docExplorerStore);
265265

266266
export const useDocExplorer = () =>
267267
useDocExplorerStore(state => state.explorerNavStack);

packages/graphiql-plugin-explorer/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
".": "./dist/index.js"
2727
},
2828
"scripts": {
29+
"types:check": "tsc --noEmit",
2930
"dev": "vite build --watch",
3031
"build": "vite build && UMD=true vite build",
31-
"postbuild": "cp src/graphiql-explorer.d.ts dist/graphiql-explorer.d.ts",
32-
"prebuild": "yarn types:check",
33-
"types:check": "tsc --noEmit"
32+
"postbuild": "cp src/graphiql-explorer.d.ts dist/graphiql-explorer.d.ts"
3433
},
3534
"dependencies": {
3635
"graphiql-explorer": "^0.9.0"

packages/graphiql-plugin-history/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"dist"
3030
],
3131
"scripts": {
32+
"types:check": "tsc --noEmit",
3233
"dev": "vite build --watch",
3334
"build": "vite build",
34-
"test": "vitest",
35-
"types:check": "tsc --noEmit"
35+
"test": "vitest"
3636
},
3737
"peerDependencies": {
3838
"react": "^18 || ^19",

packages/graphiql-plugin-history/src/context.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// eslint-disable-next-line react/jsx-filename-extension -- TODO
22
import { FC, ReactElement, ReactNode, useEffect } from 'react';
3-
import { createStore, useStore } from 'zustand';
3+
import { createStore } from 'zustand';
44
import { HistoryStore, QueryStoreItem } from '@graphiql/toolkit';
55
import {
66
useExecutionContext,
77
useEditorContext,
88
useStorage,
9+
createBoundedUseStore,
910
} from '@graphiql/react';
1011

1112
const historyStore = createStore<HistoryContextType>((set, get) => ({
@@ -146,9 +147,7 @@ export const HistoryContextProvider: FC<HistoryContextProviderProps> = ({
146147
return children as ReactElement;
147148
};
148149

149-
function useHistoryStore<T>(selector: (state: HistoryContextType) => T): T {
150-
return useStore(historyStore, selector);
151-
}
150+
const useHistoryStore = createBoundedUseStore(historyStore);
152151

153152
export const useHistory = () =>
154153
useHistoryStore(state => state.historyStorage.queries);

0 commit comments

Comments
 (0)