Skip to content

Commit

Permalink
refactor: to remove query to load menu feature toggles (#3578)
Browse files Browse the repository at this point in the history
* refactor: to remove query to load menu feature toggles

* chore: add changeset
  • Loading branch information
tdeekens committed Aug 5, 2024
1 parent 3f3c6aa commit 839d185
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 195 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-vans-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@commercetools-frontend/application-shell": patch
---

Remove usage of query to load menu feature toggles.
8 changes: 0 additions & 8 deletions @types-extensions/graphql-proxy/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/* THIS IS A GENERATED FILE */
/* eslint-disable import/no-duplicates */

declare module '*/fetch-all-menu-feature-toggles.proxy.graphql' {
import { DocumentNode } from 'graphql';
const defaultDocument: DocumentNode;
export const FetchAllMenuFeatureToggles: DocumentNode;

export default defaultDocument;
}

declare module '*/fetch-applications-menu.proxy.graphql' {
import { DocumentNode } from 'graphql';
const defaultDocument: DocumentNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ const getDefaultMockResolvers = (mocks = {}) => {
})
)
),
graphql
.link(`${window.location.origin}/api/graphql`)
.query('FetchAllMenuFeatureToggles', (req, res, ctx) =>
res(ctx.data({ allFeatureToggles: [] }))
),
];
};
const mockServer = setupServer(
Expand Down Expand Up @@ -1344,11 +1339,6 @@ describe('navbar menu links interactions', () => {
})
)
),
graphql
.link(`${window.location.origin}/api/graphql`)
.query('FetchAllMenuFeatureToggles', (req, res, ctx) =>
res(ctx.data({ allFeatureToggles: [] }))
),
...getDefaultMockResolvers()
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
GRAPHQL_TARGETS,
featureFlags,
} from '@commercetools-frontend/constants';
import useAllMenuFeatureToggles from '../../hooks/use-all-menu-feature-toggles';
import type {
TAllFeaturesQuery,
TFetchLoggedInUserQuery,
Expand Down Expand Up @@ -122,7 +121,6 @@ export const SetupFlopFlipProvider = (props: TSetupFlopFlipProviderProps) => {
TAdditionalEnvironmentProperties['enableLongLivedFeatureFlags'],
TAdditionalEnvironmentProperties
>((context) => context.environment.enableLongLivedFeatureFlags);
const allMenuFeatureToggles = useAllMenuFeatureToggles();
const flags = useMemo(
() => ({
...featureFlags.FLAGS,
Expand All @@ -141,10 +139,9 @@ export const SetupFlopFlipProvider = (props: TSetupFlopFlipProviderProps) => {
const defaultFlags = useMemo(
() => ({
...featureFlags.DEFAULT_FLAGS,
...allMenuFeatureToggles.allFeatureToggles,
...props.defaultFlags,
}),
[allMenuFeatureToggles.allFeatureToggles, props.defaultFlags]
[props.defaultFlags]
);

const adapterArgs = useMemo(
Expand Down Expand Up @@ -222,7 +219,7 @@ export const SetupFlopFlipProvider = (props: TSetupFlopFlipProviderProps) => {
shouldDeferAdapterConfiguration={
typeof props.shouldDeferAdapterConfiguration === 'boolean'
? props.shouldDeferAdapterConfiguration
: !props.user || allMenuFeatureToggles.isLoading
: !props.user
}
>
{props.children}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions packages/application-shell/src/types/generated/proxy.ts

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

0 comments on commit 839d185

Please sign in to comment.