Flamingo Commerce Graphql API

In Flamingo Commerce most of the modules provide GraphQL schemas and the corresponding resolvers and modifiers.

Usage

To enable graphql in your project follow the documentations in the "graphql" Flamingo module. (See GraphQL Module)

Examples

See the following example queries to get a feeling on how the Flamingo Commerce GraphQL schema can be used:

Receiving Cart

query cartexample {
  Commerce_Cart {
    cart {
      id
      itemCount
      deliveries {
        deliveryInfo {
          code
        }
        cartitems {
          qty
          productName
        }
      }
    }
  }
}

Adding a product to Cart

mutation add {
  Commerce_AddToCart(marketplaceCode: "awesome-retailer_7409939", qty: 10, deliveryCode: "delivery") {
    cart {
      id
    }
}
}

Receiving Products

query productssimple {
  Commerce_Product(marketplaceCode: "awesome-retailer_7409939") {
   ...productData
  }
}


fragment productData on Commerce_Product {
baseData {
      title
    }
  isSaleable
  saleableData {
    activePrice {
      default {
        amount
        currency
      }
      discounted {
        amount
        currency
      }
      discountText
      isDiscounted
    }
  }
}

This example uses GraphQL Fragments to share the common set of properties.

Typed Products

Product is an interface and there can be many types implementing it. You can modify the query like this:

query productstyped {
  Commerce_Product(marketplaceCode: "awesome-retailer_7409939") {
   __typename
    ... on Commerce_SimpleProduct {
      ...productData
    }
  }
}