saleor-dashboard/src/products/queries.ts
Dominik Żegleń 8fc48eb5f2
Allow all attributes to appear in grid in PLP (#1933)
* Remove unnecessary attribute filtering

* Enable all attribute types to be displayed in plp

* Improve attribute rendering in plp

* Remove obsolete filters

* Add story

* Rmove dashboard settings section

* Update snapshots

* Remove unused import

* Add column search

* Fix type

* Update messages

* Allow popper to appear on top of select

* Update snapshots

* Update label

* Use autocomplete from macaw

* Fix stories

* Remove unused imports

* Update macaw

* Update message

* Update messages and snapshots
2022-04-28 10:43:05 +02:00

280 lines
5.1 KiB
TypeScript

import { gql } from "@apollo/client";
export const initialProductFilterAttributesQuery = gql`
query InitialProductFilterAttributes {
attributes(first: 100, filter: { type: PRODUCT_TYPE }) {
edges {
node {
id
name
inputType
slug
}
}
}
}
`;
export const initialProductFilterCategoriesQuery = gql`
query InitialProductFilterCategories($categories: [ID!]) {
categories(first: 100, filter: { ids: $categories }) {
edges {
node {
id
name
}
}
}
}
`;
export const initialProductFilterCollectionsQuery = gql`
query InitialProductFilterCollections($collections: [ID!]) {
collections(first: 100, filter: { ids: $collections }) {
edges {
node {
id
name
}
}
}
}
`;
export const initialProductFilterProductTypesQuery = gql`
query InitialProductFilterProductTypes($productTypes: [ID!]) {
productTypes(first: 100, filter: { ids: $productTypes }) {
edges {
node {
id
name
}
}
}
}
`;
export const productListQuery = gql`
query ProductList(
$first: Int
$after: String
$last: Int
$before: String
$filter: ProductFilterInput
$channel: String
$sort: ProductOrder
$hasChannel: Boolean!
$hasSelectedAttributes: Boolean!
) {
products(
before: $before
after: $after
first: $first
last: $last
filter: $filter
sortBy: $sort
channel: $channel
) {
edges {
node {
...ProductWithChannelListings
updatedAt
attributes @include(if: $hasSelectedAttributes) {
...ProductListAttribute
}
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
totalCount
}
}
`;
export const productCountQuery = gql`
query ProductCount($filter: ProductFilterInput, $channel: String) {
products(filter: $filter, channel: $channel) {
totalCount
}
}
`;
export const productDetailsQuery = gql`
query ProductDetails(
$id: ID!
$channel: String
$firstValues: Int
$afterValues: String
$lastValues: Int
$beforeValues: String
) {
product(id: $id, channel: $channel) {
...Product
}
taxTypes {
...TaxType
}
}
`;
export const productTypeQuery = gql`
query ProductType(
$id: ID!
$firstValues: Int
$afterValues: String
$lastValues: Int
$beforeValues: String
) {
productType(id: $id) {
id
name
hasVariants
productAttributes {
id
inputType
entityType
slug
name
valueRequired
unit
choices(
first: $firstValues
after: $afterValues
last: $lastValues
before: $beforeValues
) {
...AttributeValueList
}
}
taxType {
...TaxType
}
}
}
`;
export const productVariantQuery = gql`
query ProductVariantDetails(
$id: ID!
$firstValues: Int
$afterValues: String
$lastValues: Int
$beforeValues: String
) {
productVariant(id: $id) {
...ProductVariant
}
}
`;
export const productVariantCreateQuery = gql`
query ProductVariantCreateData(
$id: ID!
$firstValues: Int
$afterValues: String
$lastValues: Int
$beforeValues: String
) {
product(id: $id) {
id
media {
id
sortOrder
url
}
channelListings {
channel {
id
name
currencyCode
}
}
name
productType {
id
selectionVariantAttributes: variantAttributes(
variantSelection: VARIANT_SELECTION
) {
...VariantAttribute
}
nonSelectionVariantAttributes: variantAttributes(
variantSelection: NOT_VARIANT_SELECTION
) {
...VariantAttribute
}
}
thumbnail {
url
}
variants {
id
name
sku
media {
id
url
type
}
}
}
}
`;
export const productMediaQuery = gql`
query ProductMediaById($productId: ID!, $mediaId: ID!) {
product(id: $productId) {
id
name
mainImage: mediaById(id: $mediaId) {
id
alt
url
type
oembedData
}
media {
id
url(size: 48)
alt
type
oembedData
}
}
}
`;
export const gridAttributes = gql`
query GridAttributes($ids: [ID!]!) {
grid: attributes(first: 25, filter: { ids: $ids }) {
edges {
node {
id
name
}
}
}
}
`;
export const createMultipleVariantsData = gql`
query CreateMultipleVariantsData(
$id: ID!
$firstValues: Int
$afterValues: String
$lastValues: Int
$beforeValues: String
) {
product(id: $id) {
...ProductVariantAttributes
}
warehouses(first: 20) {
edges {
node {
...Warehouse
}
}
}
}
`;