Skip to content

Commit 20a3eae

Browse files
authored
Merge pull request #66 from HSLdevcom/update-graphiql
DT-6903 - Update GraphiQL to version 4.1.0
2 parents b14b73d + 5d69fe6 commit 20a3eae

File tree

5 files changed

+1012
-555
lines changed

5 files changed

+1012
-555
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ module.exports = {
7171
plugins: ['react', 'compat', 'prettier', 'jsx-a11y'],
7272
settings: {
7373
polyfills: ['fetch', 'promises'],
74+
'import/resolver': {
75+
typescript: {},
76+
},
7477
},
7578
};

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"packageManager": "yarn@4.5.1",
99
"private": true,
1010
"dependencies": {
11-
"graphiql": "^3.7.1",
12-
"graphql": "^16.9.0",
13-
"react": "^18.3.1",
14-
"react-dom": "^18.3.1",
15-
"react-router-dom": "^6.28.0"
11+
"graphiql": "^4.1.0",
12+
"graphql": "^16.11.0",
13+
"react": "^19.1.0",
14+
"react-dom": "^19.1.0",
15+
"react-router-dom": "^7.6.1"
1616
},
1717
"scripts": {
1818
"start": "vite",
@@ -50,13 +50,14 @@
5050
"eslint": "8.56.0",
5151
"eslint-config-airbnb": "19.0.4",
5252
"eslint-config-prettier": "9.1.0",
53+
"eslint-import-resolver-typescript": "^4.4.1",
5354
"eslint-plugin-compat": "^6.0.1",
5455
"eslint-plugin-import": "^2.31.0",
5556
"eslint-plugin-jsx-a11y": "^6.10.2",
5657
"eslint-plugin-prettier": "^5.2.1",
5758
"eslint-plugin-react": "^7.37.2",
5859
"eslint-plugin-react-hooks": "^4.3.0",
59-
"graphql-ws": "^5.16.0",
60+
"graphql-ws": "^6.0.5",
6061
"jsdom": "^25.0.1",
6162
"prettier": "^3.3.3",
6263
"vite": "^5.4.11",

src/config.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ export const CONFIGS = [
8181
{
8282
router: 'hsl',
8383
api: {
84-
[API_VERSION_1]: {
85-
title: 'HSL (v1 Deprecated)',
86-
routerUrl: {
87-
[API_TYPE.DEV]: buildUrl(API_TYPE.DEV, API_VERSION_1, 'hsl'),
88-
[API_TYPE.PROD]: buildUrl(API_TYPE.PROD, API_VERSION_1, 'hsl'),
89-
},
90-
},
9184
[API_VERSION_2]: {
9285
title: 'HSL (v2)',
9386
dialect: {
@@ -120,13 +113,6 @@ export const CONFIGS = [
120113
{
121114
router: 'waltti',
122115
api: {
123-
[API_VERSION_1]: {
124-
title: 'Waltti (v1 Deprecated)',
125-
routerUrl: {
126-
[API_TYPE.DEV]: buildUrl(API_TYPE.DEV, API_VERSION_1, 'waltti'),
127-
[API_TYPE.PROD]: buildUrl(API_TYPE.PROD, API_VERSION_1, 'waltti'),
128-
},
129-
},
130116
[API_VERSION_2]: {
131117
title: 'Waltti (v2)',
132118
dialect: {
@@ -159,13 +145,6 @@ export const CONFIGS = [
159145
{
160146
router: 'finland',
161147
api: {
162-
[API_VERSION_1]: {
163-
title: 'Finland (v1 Deprecated)',
164-
routerUrl: {
165-
[API_TYPE.DEV]: buildUrl(API_TYPE.DEV, API_VERSION_1, 'finland'),
166-
[API_TYPE.PROD]: buildUrl(API_TYPE.PROD, API_VERSION_1, 'finland'),
167-
},
168-
},
169148
[API_VERSION_2]: {
170149
title: 'Finland (v2)',
171150
dialect: {

src/graphiql/CustomGraphiQL.jsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { useLocation, useNavigate } from 'react-router-dom';
3-
import GraphiQL from 'graphiql';
3+
import { GraphiQL } from 'graphiql';
44
import { ToolbarMenu } from '@graphiql/react';
55
import graphQLFetcher from '../api/graphQLFetcher';
66
import 'graphiql/graphiql.css';
@@ -31,10 +31,13 @@ const GraphiQLWithCustomToolbar = ({
3131
operationName={operationName || undefined}
3232
onEditQuery={query => setQuery(query)}
3333
onEditVariables={variables => setVariables(variables)}
34-
onEditOperationName={operationName => setOperationName(operationName)}
35-
toolbar={{
36-
additionalContent: (
34+
onEditOperationName={operationName => setOperationName(operationName)}>
35+
<GraphiQL.Toolbar>
36+
{({ merge, prettify, copy }) => (
3737
<>
38+
{prettify}
39+
{merge}
40+
{copy}
3841
<ToolbarMenu
3942
button={<div className="customgraphiql-toolbarmenu-button">EP</div>}
4043
label={`Endpoint: ${config.title}`}>
@@ -88,9 +91,13 @@ const GraphiQLWithCustomToolbar = ({
8891
)}
8992
</ToolbarMenu>
9093
</>
91-
),
92-
}}
93-
/>
94+
)}
95+
</GraphiQL.Toolbar>
96+
<GraphiQL.Footer>
97+
<b>API:</b> {apiType ? API_CONFIG[apiType].label : ''} - <b>Endpoint:</b>{' '}
98+
{config.title}
99+
</GraphiQL.Footer>
100+
</GraphiQL>
94101
);
95102

96103
const QUERY_STRING_PARAMS = ['query', 'variables', 'operationName'];

0 commit comments

Comments
 (0)