saleor-dashboard/src/products/queries.ts
Dominik Żegleń 5b85d6c086
Use graphql-codegen (#1874)
* Use generated hooks in apps

* Remove unused files

* Use proper types in apps

* Use generated hooks in attributes

* Use generated hooks in auth module

* Use generated hooks in categories

* Use generated hooks in channels

* Use generated types in collections

* Remove legacy types from background tasks

* Use generated hooks in customers

* Use generated hooks in discounts

* Use generated hook in file upload

* Use generated types in gift cards

* Use generated types in home

* Use generated hooks in navigation

* Use generated hooks in orders

* Use generated hooks in pages

* Use generated hooks in page types

* Use generated hooks in permission groups

* Use generated hooks in plugins

* Use generated hooks in products

* Use fragment to mark product variants

* Improve code a bit

* Use generated hooks in page types

* Use generated types in searches

* Use generated hooks in shipping

* Use generated hooks in site settings

* Use generated hooks in staff members

* Use generated hooks in taxes

* Place all gql generated files in one directory

* Use generated hooks in translations

* Use global types from new generated module

* Use generated hooks in warehouses

* Use generated hooks in webhooks

* Use generated fragment types

* Unclutter types

* Remove hoc components

* Split hooks and types

* Fetch introspection file

* Delete obsolete schema file

* Fix rebase artifacts

* Fix autoreplace

* Fix auth provider tests

* Fix urls

* Remove leftover types

* Fix rebase artifacts
2022-03-09 09:56:55 +01:00

313 lines
5.7 KiB
TypeScript

import { gql } from "@apollo/client";
export const initialProductFilterAttributesQuery = gql`
query InitialProductFilterAttributes {
attributes(
first: 100
filter: { filterableInDashboard: true, 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) {
attribute {
id
}
values {
...AttributeValue
}
}
}
}
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 availableInGridAttributes = gql`
query AvailableInGridAttributes($first: Int!, $after: String) {
availableInGrid: attributes(
first: $first
after: $after
filter: {
availableInGrid: true
isVariantOnly: false
type: PRODUCT_TYPE
}
) {
edges {
node {
id
name
}
}
pageInfo {
...PageInfo
}
totalCount
}
}
`;
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
}
}
}
}
`;