Skip to content

Commit c114633

Browse files
committed
Just use plain fetch
1 parent 2798c97 commit c114633

28 files changed

+130
-106
lines changed

frontend/package-lock.json

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
"@zxcvbn-ts/language-common": "^3.0.4",
3535
"classnames": "^2.5.1",
3636
"date-fns": "^4.1.0",
37-
"graphql": "^16.9.0",
38-
"graphql-request": "^7.1.2",
3937
"i18next": "^23.16.5",
4038
"react": "^18.3.1",
4139
"react-dom": "^18.3.1",

frontend/src/components/BrowserSession.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
import IconChrome from "@browser-logos/chrome/chrome_64x64.png?url";
88
import IconFirefox from "@browser-logos/firefox/firefox_64x64.png?url";
99
import IconSafari from "@browser-logos/safari/safari_64x64.png?url";
10+
import { useMutation, useQueryClient } from "@tanstack/react-query";
1011
import { Badge } from "@vector-im/compound-web";
1112
import { parseISO } from "date-fns";
1213
import { useCallback } from "react";
1314
import { useTranslation } from "react-i18next";
14-
1515
import { type FragmentType, graphql, useFragment } from "../gql";
16-
17-
import { useMutation, useQueryClient } from "@tanstack/react-query";
18-
import { graphqlClient } from "../graphql";
16+
import { graphqlRequest } from "../graphql";
1917
import DateTime from "./DateTime";
2018
import EndSessionButton from "./Session/EndSessionButton";
2119
import LastActive from "./Session/LastActive";
@@ -61,7 +59,7 @@ export const useEndBrowserSession = (
6159
const queryClient = useQueryClient();
6260
const endSession = useMutation({
6361
mutationFn: (id: string) =>
64-
graphqlClient.request(END_SESSION_MUTATION, { id }),
62+
graphqlRequest({ query: END_SESSION_MUTATION, variables: { id } }),
6563
onSuccess: (data) => {
6664
queryClient.invalidateQueries({ queryKey: ["sessionsOverview"] });
6765
queryClient.invalidateQueries({ queryKey: ["browserSessionList"] });

frontend/src/components/CompatSession.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { parseISO } from "date-fns";
99
import { useTranslation } from "react-i18next";
1010
import { type FragmentType, graphql, useFragment } from "../gql";
11-
import { graphqlClient } from "../graphql";
11+
import { graphqlRequest } from "../graphql";
1212
import { browserLogoUri } from "./BrowserSession";
1313
import DateTime from "./DateTime";
1414
import EndSessionButton from "./Session/EndSessionButton";
@@ -76,7 +76,7 @@ const CompatSession: React.FC<{
7676
const queryClient = useQueryClient();
7777
const endSession = useMutation({
7878
mutationFn: (id: string) =>
79-
graphqlClient.request(END_SESSION_MUTATION, { id }),
79+
graphqlRequest({ query: END_SESSION_MUTATION, variables: { id } }),
8080
onSuccess: (data) => {
8181
queryClient.invalidateQueries({ queryKey: ["sessionsOverview"] });
8282
queryClient.invalidateQueries({ queryKey: ["appSessionList"] });

frontend/src/components/Layout/Layout.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
// SPDX-License-Identifier: AGPL-3.0-only
55
// Please see LICENSE in the repository root for full details.
66

7+
import { queryOptions, useQuery } from "@tanstack/react-query";
78
import cx from "classnames";
89
import { Suspense } from "react";
9-
1010
import { graphql } from "../../gql";
11+
import { graphqlRequest } from "../../graphql";
1112
import Footer from "../Footer";
12-
13-
import { queryOptions, useQuery } from "@tanstack/react-query";
14-
import { graphqlClient } from "../../graphql";
1513
import styles from "./Layout.module.css";
1614

1715
const QUERY = graphql(/* GraphQL */ `
@@ -25,7 +23,7 @@ const QUERY = graphql(/* GraphQL */ `
2523

2624
export const query = queryOptions({
2725
queryKey: ["footer"],
28-
queryFn: ({ signal }) => graphqlClient.request({ document: QUERY, signal }),
26+
queryFn: ({ signal }) => graphqlRequest({ query: QUERY, signal }),
2927
});
3028

3129
const AsyncFooter: React.FC = () => {

frontend/src/components/OAuth2Session.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { parseISO } from "date-fns";
99
import { useTranslation } from "react-i18next";
1010
import { type FragmentType, graphql, useFragment } from "../gql";
1111
import type { DeviceType, Oauth2ApplicationType } from "../gql/graphql";
12-
import { graphqlClient } from "../graphql";
12+
import { graphqlRequest } from "../graphql";
1313
import { getDeviceIdFromScope } from "../utils/deviceIdFromScope";
1414
import DateTime from "./DateTime";
1515
import EndSessionButton from "./Session/EndSessionButton";
@@ -75,7 +75,7 @@ const OAuth2Session: React.FC<Props> = ({ session }) => {
7575
const queryClient = useQueryClient();
7676
const endSession = useMutation({
7777
mutationFn: (id: string) =>
78-
graphqlClient.request(END_SESSION_MUTATION, { id }),
78+
graphqlRequest({ query: END_SESSION_MUTATION, variables: { id } }),
7979
onSuccess: (data) => {
8080
queryClient.invalidateQueries({ queryKey: ["sessionsOverview"] });
8181
queryClient.invalidateQueries({ queryKey: ["appSessionList"] });

frontend/src/components/SessionDetail/CompatSessionDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { parseISO } from "date-fns";
99
import { useTranslation } from "react-i18next";
1010
import { type FragmentType, graphql, useFragment } from "../../gql";
11-
import { graphqlClient } from "../../graphql";
11+
import { graphqlRequest } from "../../graphql";
1212
import BlockList from "../BlockList/BlockList";
1313
import { END_SESSION_MUTATION, simplifyUrl } from "../CompatSession";
1414
import DateTime from "../DateTime";
@@ -46,7 +46,7 @@ const CompatSessionDetail: React.FC<Props> = ({ session }) => {
4646
const queryClient = useQueryClient();
4747
const endSession = useMutation({
4848
mutationFn: (id: string) =>
49-
graphqlClient.request(END_SESSION_MUTATION, { id }),
49+
graphqlRequest({ query: END_SESSION_MUTATION, variables: { id } }),
5050
onSuccess: (data) => {
5151
queryClient.invalidateQueries({ queryKey: ["sessionsOverview"] });
5252
queryClient.invalidateQueries({ queryKey: ["appSessionList"] });

frontend/src/components/SessionDetail/OAuth2SessionDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { parseISO } from "date-fns";
99
import { useTranslation } from "react-i18next";
1010
import { type FragmentType, graphql, useFragment } from "../../gql";
11-
import { graphqlClient } from "../../graphql";
11+
import { graphqlRequest } from "../../graphql";
1212
import { getDeviceIdFromScope } from "../../utils/deviceIdFromScope";
1313
import BlockList from "../BlockList/BlockList";
1414
import DateTime from "../DateTime";
@@ -46,7 +46,7 @@ const OAuth2SessionDetail: React.FC<Props> = ({ session }) => {
4646
const queryClient = useQueryClient();
4747
const endSession = useMutation({
4848
mutationFn: (id: string) =>
49-
graphqlClient.request(END_SESSION_MUTATION, { id }),
49+
graphqlRequest({ query: END_SESSION_MUTATION, variables: { id } }),
5050
onSuccess: (data) => {
5151
queryClient.invalidateQueries({ queryKey: ["sessionsOverview"] });
5252
queryClient.invalidateQueries({ queryKey: ["appSessionList"] });

frontend/src/components/UserEmail/UserEmail.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import { Translation, useTranslation } from "react-i18next";
1212
import { type FragmentType, graphql, useFragment } from "../../gql";
1313
import { Close, Description, Dialog, Title } from "../Dialog";
1414
import { Link } from "../Link";
15-
1615
import { useMutation, useQueryClient } from "@tanstack/react-query";
17-
import { graphqlClient } from "../../graphql";
1816
import styles from "./UserEmail.module.css";
17+
import { graphqlRequest } from "../../graphql";
1918

2019
// This component shows a single user email address, with controls to verify it,
2120
// resend the verification email, remove it, and set it as the primary email address.
@@ -136,7 +135,7 @@ const UserEmail: React.FC<{
136135

137136
const setPrimary = useMutation({
138137
mutationFn: (id: string) =>
139-
graphqlClient.request(SET_PRIMARY_EMAIL_MUTATION, { id }),
138+
graphqlRequest({ query: SET_PRIMARY_EMAIL_MUTATION, variables: { id } }),
140139
onSuccess: (_data) => {
141140
queryClient.invalidateQueries({ queryKey: ["currentUserGreeting"] });
142141
queryClient.invalidateQueries({ queryKey: ["userEmails"] });
@@ -145,7 +144,7 @@ const UserEmail: React.FC<{
145144

146145
const removeEmail = useMutation({
147146
mutationFn: (id: string) =>
148-
graphqlClient.request(REMOVE_EMAIL_MUTATION, { id }),
147+
graphqlRequest({ query: REMOVE_EMAIL_MUTATION, variables: { id } }),
149148
onSuccess: (_data) => {
150149
onRemove?.();
151150
queryClient.invalidateQueries({ queryKey: ["currentUserGreeting"] });

frontend/src/components/UserGreeting/UserGreeting.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import {
2323
} from "react";
2424
import { useTranslation } from "react-i18next";
2525
import { type FragmentType, graphql, useFragment } from "../../gql";
26-
import { graphqlClient } from "../../graphql";
2726
import * as Dialog from "../Dialog";
2827
import LoadingSpinner from "../LoadingSpinner";
2928
import styles from "./UserGreeting.module.css";
29+
import { graphqlRequest } from "../../graphql";
3030

3131
export const FRAGMENT = graphql(/* GraphQL */ `
3232
fragment UserGreeting_user on User {
@@ -92,8 +92,14 @@ const UserGreeting: React.FC<Props> = ({ user, siteConfig }) => {
9292
mutationFn: ({
9393
userId,
9494
displayName,
95-
}: { userId: string; displayName: string | null }) =>
96-
graphqlClient.request(SET_DISPLAYNAME_MUTATION, { userId, displayName }),
95+
}: {
96+
userId: string;
97+
displayName: string | null;
98+
}) =>
99+
graphqlRequest({
100+
query: SET_DISPLAYNAME_MUTATION,
101+
variables: { userId, displayName },
102+
}),
97103
onSuccess: (data) => {
98104
queryClient.invalidateQueries({ queryKey: ["currentUserGreeting"] });
99105
if (data.setDisplayName.status === "SET") {

0 commit comments

Comments
 (0)