Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-carpets-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Pull @saleor/sdk dependency into Dashboard codebase, to restore control of external dependencies like Apollo
4 changes: 3 additions & 1 deletion codegen-main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodegenConfig } from "@graphql-codegen/cli";
import { type CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
schema: "./schema-main.graphql",
Expand All @@ -12,6 +12,8 @@ const config: CodegenConfig = {
"!./src/**/mutations.staging.ts",
"!./src/**/fragments/*.staging.ts",
"!./src/searches/*.staging.ts",
// legacy SDK has its own internal GraphQL operations
"!./src/legacy-sdk/**",
],
generates: {
"./src/graphql/fragmentTypes.generated.ts": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"@react-editor-js/core": "2.1.0",
"@saleor/macaw-ui": "npm:@saleor/macaw-ui@0.7.4",
"@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.4.2",
"@saleor/sdk": "0.6.0",
"@sentry/react": "^8.55.0",
"@sentry/vite-plugin": "^2.23.1",
"@types/faker": "^5.5.9",
Expand Down
24 changes: 0 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ blockExoticSubdeps: true
minimumReleaseAge: 720 # 12h
minimumReleaseAgeExclude:
- "@saleor/app-sdk"
- "@saleor/sdk"
- "@saleor/macaw-ui"

trustPolicy: no-downgrade
Expand Down
4 changes: 2 additions & 2 deletions src/auth/AuthProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useApolloClient } from "@apollo/client";
import { useUserDetailsQuery } from "@dashboard/graphql";
import { useNotifier } from "@dashboard/hooks/useNotifier";
import { useAuth, useAuthState } from "@saleor/sdk";
import { useAuth, useAuthState } from "@dashboard/legacy-sdk";
import { act, renderHook } from "@testing-library/react-hooks";
import { useIntl } from "react-intl";

Expand Down Expand Up @@ -38,7 +38,7 @@ afterAll(() => {
value: originalWindowNavigator,
});
});
jest.mock("@saleor/sdk", () => ({
jest.mock("@dashboard/legacy-sdk", () => ({
useAuth: jest.fn(() => ({
login: jest.fn(() => ({
data: {
Expand Down
4 changes: 2 additions & 2 deletions src/auth/hooks/useAuthProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApolloError } from "@apollo/client";
import { AccountErrorCode } from "@dashboard/graphql";
import { useAuth, useAuthState } from "@saleor/sdk";
import { useAuth, useAuthState } from "@dashboard/legacy-sdk";
import { waitFor } from "@testing-library/react";
import { act, renderHook } from "@testing-library/react-hooks";

import { useAuthProvider } from "./useAuthProvider";

// Mock dependencies
jest.mock("@saleor/sdk");
jest.mock("@dashboard/legacy-sdk");

const useAuthStateMock = {
authenticated: false,
Expand Down
12 changes: 6 additions & 6 deletions src/auth/hooks/useAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { AccountErrorCode, useUserDetailsQuery } from "@dashboard/graphql";
import useLocalStorage from "@dashboard/hooks/useLocalStorage";
import useNavigator from "@dashboard/hooks/useNavigator";
import { commonMessages } from "@dashboard/intl";
import {
type GetExternalAccessTokenData,
type LoginData,
useAuth,
useAuthState,
} from "@dashboard/legacy-sdk";
import {
checkIfCredentialsExist,
isSupported as isCredentialsManagementAPISupported,
login as loginWithCredentialsManagementAPI,
saveCredentials,
} from "@dashboard/utils/credentialsManagement";
import { getAppMountUriForRedirect } from "@dashboard/utils/urls";
import {
type GetExternalAccessTokenData,
type LoginData,
useAuth,
useAuthState,
} from "@saleor/sdk";
import isEmpty from "lodash/isEmpty";
import { useEffect, useRef, useState } from "react";
import { type IntlShape } from "react-intl";
Expand Down
2 changes: 1 addition & 1 deletion src/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type GetExternalAccessTokenData,
type GetExternalAuthUrlData,
type LoginData,
} from "@saleor/sdk";
} from "@dashboard/legacy-sdk";

export interface RequestExternalLoginInput {
redirectUri: string;
Expand Down
2 changes: 1 addition & 1 deletion src/auth/views/NewPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AccountErrorFragment } from "@dashboard/graphql";
import useNavigator from "@dashboard/hooks/useNavigator";
import { useAuth } from "@dashboard/legacy-sdk";
import { parseQs } from "@dashboard/url-utils";
import { useAuth } from "@saleor/sdk";
import { useState } from "react";
import { type RouteComponentProps } from "react-router";

Expand Down
2 changes: 1 addition & 1 deletion src/components/AddressEdit/useAddressValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CountryCode,
useAddressValidationRulesQuery,
} from "@dashboard/graphql";
import { type ChoiceValue } from "@saleor/sdk/dist/apollo/types";
import { type ChoiceValue } from "@dashboard/legacy-sdk/apollo/types";

interface AreaChoices {
label: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppLayout/AppChannelContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { useUser } from "@dashboard/auth/useUser";
import { type ChannelFragment, useBaseChannelsQuery } from "@dashboard/graphql";
import useLocalStorage from "@dashboard/hooks/useLocalStorage";
import { useSaleorConfig } from "@dashboard/legacy-sdk";
import { getById } from "@dashboard/misc";
import { useSaleorConfig } from "@saleor/sdk";
import { createContext, type ReactNode, useContext, useEffect, useState } from "react";

interface UseAppChannel {
Expand Down
4 changes: 2 additions & 2 deletions src/components/DevModePanel/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { getApiUrl } from "@dashboard/config";
import { createFetch } from "@dashboard/legacy-sdk";
import { createGraphiQLFetcher, type FetcherOpts } from "@graphiql/toolkit";
import { createFetch } from "@saleor/sdk";

import { getFetcher } from "./utils";

jest.mock("@graphiql/toolkit", () => ({
createGraphiQLFetcher: jest.fn(),
}));

jest.mock("@saleor/sdk", () => ({
jest.mock("@dashboard/legacy-sdk", () => ({
createFetch: jest.fn().mockReturnValue(jest.fn()),
}));

Expand Down
2 changes: 1 addition & 1 deletion src/components/DevModePanel/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ENABLED_SERVICE_NAME_HEADER, getApiUrl } from "@dashboard/config";
import { createFetch } from "@dashboard/legacy-sdk";
import { createGraphiQLFetcher, type FetcherOpts } from "@graphiql/toolkit";
import { createFetch } from "@saleor/sdk";

const authHeaders = ["Authorization", "Authorization-Bearer"];

Expand Down
3 changes: 1 addition & 2 deletions src/graphql/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// These are separate clients and do not share configs between themselves
import { ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client";
import { ENABLED_SERVICE_NAME_HEADER, getApiUrl } from "@dashboard/config";
import { createFetch, createSaleorClient } from "@saleor/sdk";
import { createFetch, createSaleorClient } from "@dashboard/legacy-sdk";
import { createUploadLink } from "apollo-upload-client";

import introspectionQueryResultData from "./fragmentTypes.generated";
Expand Down Expand Up @@ -41,7 +41,6 @@ const link = attachVariablesLink.concat(
createUploadLink({
credentials: "include",
uri: getApiUrl(),
// TODO: Remove once @saleor/sdk is removed in favor of local implementation for auth
// Note this has to be as typeof fetch: ts-expect-error breaks TS in non-strict mode, without it strict mode breaks
fetch: createFetch() as typeof fetch,
}) as unknown as ApolloLink, // type mismatch between apollo-upload-client and @apollo/cient
Expand Down
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { AppExtensionPopupProvider } from "@dashboard/extensions/components/AppE
import { ExtensionsPaths, extensionsSection } from "@dashboard/extensions/urls";
import { PermissionEnum } from "@dashboard/graphql";
import useAppState from "@dashboard/hooks/useAppState";
import { SaleorProvider } from "@dashboard/legacy-sdk";
import { pageListPath } from "@dashboard/modeling/urls";
import { modelTypesPath } from "@dashboard/modelTypes/urls";
import { refundsSettingsPath } from "@dashboard/refundsSettings/urls";
import { structuresListPath } from "@dashboard/structures/urls";
import { ThemeProvider } from "@dashboard/theme";
import { OnboardingProvider } from "@dashboard/welcomePage/WelcomePageOnboarding/onboardingContext";
import { ThemeProvider as LegacyThemeProvider } from "@saleor/macaw-ui";
import { SaleorProvider } from "@saleor/sdk";
import { lazy, StrictMode, Suspense } from "react";
import { createRoot } from "react-dom/client";
import { ErrorBoundary } from "react-error-boundary";
Expand Down Expand Up @@ -114,7 +114,6 @@ const handleLegacyTheming = (): void => {
handleLegacyTheming();

const App = (): JSX.Element => (
// @ts-expect-error legacy types
<SaleorProvider client={saleorClient}>
<ApolloProvider client={apolloClient}>
<Router>
Expand Down
Loading
Loading