How to use the @commercetools-frontend/constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM 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 / quick-access / quick-access.js View on Github external
async searchText => {
      const idsOfProductsMatchingSearchText =
        this.props.pimIndexerState === pimIndexerStates.INDEXED
          ? await this.props.pimSearchProductIds(searchText)
          : [];

      const canViewProducts = hasSomePermissions(
        ['ViewProducts', 'ManageProducts'],
        this.props.applicationContext.permissions
      );

      return this.query(QuickAccessQuery, {
        searchText: sanitize(searchText),
        target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
        // Pass conditional arguments to disable some of the queries
        canViewProducts,
        productsWhereClause: `id in (${idsOfProductsMatchingSearchText
          .map(id => JSON.stringify(id))
          .join(', ')})`,
        includeProductsByIds: Boolean(
          canViewProducts && idsOfProductsMatchingSearchText.length > 0
        ),
      }).then(data => {
        const commands = [];

        if (containsMatchByVariantKey(data)) {
          const productId = data.productByVariantKey.id;
          const variantId =
            data.productByVariantKey.masterData.staged.variant.id;
          commands.push({
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / token-retry-link.spec.js View on Github external
it('should support the `ctp` GraphQL target', () => {
    expect(
      getDoesGraphQLTargetSupportTokenRetry({
        'X-Graphql-Target': GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
      })
    ).toBe(true);
  });
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / quick-access / sub-commands.js View on Github external
export const createProductVariantListSubCommands = ({
  applicationContext,
  intl,
  query,
  productId,
}) =>
  hasSomePermissions(
    [permissions.ViewProducts, permissions.ManageProducts],
    applicationContext.permissions
  )
    ? query(QuickAccessProductQuery, {
        productId,
        target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
      }).then(data =>
        data.product.masterData.staged.allVariants.map(variant => ({
          id: `go/product(${productId})/variant(${variant.id})`,
          text: formatVariantMessage(variant, intl),
          subCommands: createProductVariantSubCommands({
            intl,
            applicationContext,
            productId,
            variantId: variant.id,
          }),
          action: {
            type: 'go',
            to: `/${applicationContext.project.key}/products/${productId}/variants/${variant.id}`,
          },
        }))
      )
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / token-retry-link.js View on Github external
export const getDoesGraphQLTargetSupportTokenRetry = requestHeaders =>
  [
    GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
    GRAPHQL_TARGETS.ADMINISTRATION_SERVICE,
  ].includes(requestHeaders['X-Graphql-Target']);
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / quick-access / quick-access.spec.js View on Github external
const createMatchlessSearchMock = (searchText, variables = {}) => ({
  request: {
    query: QuickAccessQuery,
    variables: {
      searchText,
      target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
      canViewProducts: true,
      productsWhereClause: 'id in ()',
      includeProductsByIds: false,
      ...variables,
    },
  },
  result: {
    data: {
      productsById: null,
      productById: null,
      productByKey: null,
      productByVariantSku: null,
      productByVariantKey: null,
    },
  },
});
github commercetools / merchant-center-application-kit / packages / application-shell / src / apollo-links / token-retry-link.spec.js View on Github external
const headerLink = new ApolloLink((operation, forward) => {
          operation.setContext({
            headers: {
              'X-Graphql-Target': GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
            },
          });
          return forward(operation);
        });
        debugLink = new ApolloLink((operation, forward) => {

@commercetools-frontend/constants

Shared constants for MC applications

MIT
Latest version published 25 days ago

Package Health Score

87 / 100
Full package analysis