How to use the @commercetools-frontend/constants.GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND function in @commercetools-frontend/constants

To help you get started, we’ve selected a few @commercetools-frontend/constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / merchant-center-application-kit / packages / application-shell / src / components / authenticated / authenticated.spec.js View on Github external
beforeEach(() => {
        console.error = jest.fn();
        renderApp(, {
          mocks: [
            {
              request: {
                query: AmILoggedInQuery,
                variables: {
                  target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
                },
              },
              result: {
                data: null,
                errors: [{ message: 'Unauthorized' }],
              },
            },
          ],
        });
      });
      it('should call render with `isAuthenticated` set to false', async () => {
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / fetch-user / fetch-user.spec.js View on Github external
it('should render error state', async () => {
    const { getByText } = renderUser({
      addTypename: true,
      mocks: [
        {
          request: {
            query: LoggedInUserQuery,
            variables: {
              target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
            },
          },
          error: new Error('Oops'),
        },
      ],
    });
    await waitForElement(() => getByText(/Error: Oops/i));
  });
});
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / fetch-user / fetch-user.spec.js View on Github external
it('should fetch user and pass data to children function', async () => {
    const { getByText } = renderUser({
      addTypename: true,
      mocks: [
        {
          request: {
            query: LoggedInUserQuery,
            variables: {
              target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
            },
          },
          result: {
            data: createGraphqlResponseForUserQuery(),
          },
        },
      ],
    });
    await waitForElement(() => getByText(/John/i));
  });
  it('should render loading state', async () => {
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / header-link.spec.js View on Github external
it('should allow specifying `X-Graphql-Target`-Header', () => {
    expect(context.headers).toEqual(
      expect.objectContaining({
        'X-Graphql-Target': GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
      })
    );
  });
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / authenticated / authenticated.spec.js View on Github external
beforeEach(() => {
        renderApp(, {
          mocks: [
            {
              request: {
                query: AmILoggedInQuery,
                variables: {
                  target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
                },
              },
              result: {
                data: { loading: false, amILoggedIn: true },
              },
            },
          ],
        });
      });
      it('should call render with `isAuthenticated` set to true', async () => {
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / project-switcher / project-switcher.js View on Github external
const ProjectSwitcher = props => {
  const intl = useIntl();
  const { loading, data } = useQuery(ProjectsQuery, {
    onError: reportErrorToSentry,
    variables: {
      target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
    },
  });

  if (loading) return null;

  return (
    <div data-track-event="click" data-track-component="ProjectSwitch">
      </div>
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / header-link.spec.js View on Github external
beforeEach(async () => {
      await waitFor(
        execute(link, {
          query,
          variables: {
            target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
            projectKey,
          },
        })
      );
    });
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / fetch-user / fetch-user.js View on Github external
const FetchUser = props =&gt; {
  const { loading, data, error } = useQuery(LoggedInUserQuery, {
    onError: reportErrorToSentry,
    variables: { target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND },
  });
  return (
    &lt;&gt;
      {props.children({ isLoading: loading, user: data &amp;&amp; data.user, error })}
    
  );
};
FetchUser.displayName = 'FetchUser';
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / fetch-project / fetch-project.js View on Github external
const FetchProject = props =&gt; {
  const { loading, data, error } = useQuery(ProjectQuery, {
    onError: reportErrorToSentry,
    variables: {
      target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND,
      projectKey: props.projectKey,
    },
    skip: props.skip,
  });
  return (
    &lt;&gt;
      {props.children({
        isLoading: loading,
        error,
        project: data &amp;&amp; data.project,
      })}
    
  );
};
FetchProject.displayName = 'FetchProject';
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / header-link.spec.js View on Github external
beforeEach(async () => {
    debugLink = new ApolloLink((operation, forward) => {
      context = operation.getContext();

      return forward(operation);
    });

    terminatingLinkStub = jest.fn(() => Observable.of({}));

    link = ApolloLink.from([headerLink, debugLink, terminatingLinkStub]);

    await waitFor(
      execute(link, {
        query,
        variables: { target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND },
      })
    );
  });

@commercetools-frontend/constants

Shared constants for MC applications

MIT
Latest version published 3 days ago

Package Health Score

87 / 100
Full package analysis