From 9c8a78360d46b29d5c1cb47e3ace800bf8d300e2 Mon Sep 17 00:00:00 2001 From: Reza Babaei Date: Sat, 18 Sep 2021 00:13:44 +0300 Subject: [PATCH] fix: add get-all-pages-query --- framework/woocommerce/schema.d.ts | 142 ++++++++++++++---- framework/woocommerce/schema.graphql | 140 +++++++++-------- .../wp/queries/get-all-products-query.ts | 42 ++---- 3 files changed, 207 insertions(+), 117 deletions(-) diff --git a/framework/woocommerce/schema.d.ts b/framework/woocommerce/schema.d.ts index 4ccc1d24b..82a9cf323 100644 --- a/framework/woocommerce/schema.d.ts +++ b/framework/woocommerce/schema.d.ts @@ -8821,6 +8821,8 @@ export type Product = { localAttributes?: Maybe /** Menu order */ menuOrder?: Maybe + /** Object meta data */ + metaData?: Maybe>> /** Date product last updated */ modified?: Maybe /** Product name */ @@ -8912,6 +8914,13 @@ export type ProductLocalAttributesArgs = { where?: Maybe } +/** Product object */ +export type ProductMetaDataArgs = { + key?: Maybe + keysIn?: Maybe>> + multiple?: Maybe +} + /** Product object */ export type ProductPaColorsArgs = { first?: Maybe @@ -11269,8 +11278,6 @@ export type Refund = Node & { date?: Maybe /** The globally unique identifier for the refund */ id: Scalars['ID'] - /** Connection between the Refund type and the LineItem type */ - lineItems?: Maybe /** Object meta data */ metaData?: Maybe>> /** Reason for refund */ @@ -11281,14 +11288,6 @@ export type Refund = Node & { title?: Maybe } -/** A refund object */ -export type RefundLineItemsArgs = { - first?: Maybe - last?: Maybe - after?: Maybe - before?: Maybe -} - /** A refund object */ export type RefundMetaDataArgs = { key?: Maybe @@ -11304,26 +11303,6 @@ export enum RefundIdTypeEnum { Id = 'ID', } -/** Connection between the Refund type and the LineItem type */ -export type RefundToLineItemConnection = { - __typename?: 'RefundToLineItemConnection' - /** Edges for the RefundToLineItemConnection connection */ - edges?: Maybe>> - /** The nodes of the connection, without the edges */ - nodes?: Maybe>> - /** Information about pagination in a connection. */ - pageInfo?: Maybe -} - -/** An edge in a connection */ -export type RefundToLineItemConnectionEdge = { - __typename?: 'RefundToLineItemConnectionEdge' - /** A cursor for use in pagination */ - cursor?: Maybe - /** The item at the end of the edge */ - node?: Maybe -} - /** Input for the registerCustomer mutation */ export type RegisterCustomerInput = { /** User's AOL IM account. */ @@ -12143,8 +12122,12 @@ export type RootQuery = { customers?: Maybe /** Fields of the 'DiscussionSettings' settings group */ discussionSettings?: Maybe + /** A simple product object */ + externalProduct?: Maybe /** Fields of the 'GeneralSettings' settings group */ generalSettings?: Maybe + /** A simple product object */ + groupedProduct?: Maybe /** An object of the mediaItem Type. */ mediaItem?: Maybe /** @@ -12244,6 +12227,8 @@ export type RootQuery = { shippingMethod?: Maybe /** Connection between the RootQuery type and the ShippingMethod type */ shippingMethods?: Maybe + /** A simple product object */ + simpleProduct?: Maybe /** A 0bject */ tag?: Maybe /** Connection between the RootQuery type and the tag type */ @@ -12272,6 +12257,8 @@ export type RootQuery = { userRoles?: Maybe /** Connection between the RootQuery type and the User type */ users?: Maybe + /** A simple product object */ + variableProduct?: Maybe /** Returns the current user */ viewer?: Maybe /** A 0bject */ @@ -12387,6 +12374,18 @@ export type RootQueryCustomersArgs = { where?: Maybe } +/** The root entry point into the Graph */ +export type RootQueryExternalProductArgs = { + id?: Maybe + idType?: Maybe +} + +/** The root entry point into the Graph */ +export type RootQueryGroupedProductArgs = { + id?: Maybe + idType?: Maybe +} + /** The root entry point into the Graph */ export type RootQueryMediaItemArgs = { id: Scalars['ID'] @@ -12715,6 +12714,12 @@ export type RootQueryShippingMethodsArgs = { before?: Maybe } +/** The root entry point into the Graph */ +export type RootQuerySimpleProductArgs = { + id?: Maybe + idType?: Maybe +} + /** The root entry point into the Graph */ export type RootQueryTagArgs = { id: Scalars['ID'] @@ -12816,6 +12821,12 @@ export type RootQueryUsersArgs = { where?: Maybe } +/** The root entry point into the Graph */ +export type RootQueryVariableProductArgs = { + id?: Maybe + idType?: Maybe +} + /** The root entry point into the Graph */ export type RootQueryVisibleProductArgs = { id: Scalars['ID'] @@ -18271,6 +18282,77 @@ export type WritingSettings = { useSmilies?: Maybe } +export type GetAllProductsQueryVariables = Exact<{ + first?: Maybe +}> + +export type GetAllProductsQuery = { __typename?: 'RootQuery' } & { + products?: Maybe< + { __typename?: 'RootQueryToProductConnection' } & { + pageInfo?: Maybe< + { __typename?: 'WPPageInfo' } & Pick< + WpPageInfo, + 'hasNextPage' | 'hasPreviousPage' + > + > + edges?: Maybe< + Array< + Maybe< + { __typename?: 'RootQueryToProductConnectionEdge' } & { + node?: Maybe< + | ({ __typename?: 'ExternalProduct' } & Pick< + ExternalProduct, + 'id' | 'name' + > & { + image?: Maybe< + { __typename?: 'MediaItem' } & Pick< + MediaItem, + 'uri' | 'altText' + > + > + }) + | ({ __typename?: 'GroupProduct' } & Pick< + GroupProduct, + 'id' | 'name' + > & { + image?: Maybe< + { __typename?: 'MediaItem' } & Pick< + MediaItem, + 'uri' | 'altText' + > + > + }) + | ({ __typename?: 'SimpleProduct' } & Pick< + SimpleProduct, + 'id' | 'name' + > & { + image?: Maybe< + { __typename?: 'MediaItem' } & Pick< + MediaItem, + 'uri' | 'altText' + > + > + }) + | ({ __typename?: 'VariableProduct' } & Pick< + VariableProduct, + 'id' | 'name' + > & { + image?: Maybe< + { __typename?: 'MediaItem' } & Pick< + MediaItem, + 'uri' | 'altText' + > + > + }) + > + } + > + > + > + } + > +} + export type GetCustomerIdQueryVariables = Exact<{ [key: string]: never }> export type GetCustomerIdQuery = { __typename?: 'RootQuery' } & { diff --git a/framework/woocommerce/schema.graphql b/framework/woocommerce/schema.graphql index 25d7badc7..137738f50 100644 --- a/framework/woocommerce/schema.graphql +++ b/framework/woocommerce/schema.graphql @@ -18875,6 +18875,26 @@ interface Product { """ menuOrder: Int + """ + Object meta data + """ + metaData( + """ + Retrieve meta by key + """ + key: String + + """ + Retrieve multiple metas by key + """ + keysIn: [String] + + """ + Retrieve meta with matching keys + """ + multiple: Boolean + ): [MetaData] + """ Date product last updated """ @@ -24165,31 +24185,6 @@ type Refund implements Node { """ id: ID! - """ - Connection between the Refund type and the LineItem type - """ - lineItems( - """ - The number of items to return after the referenced "after" cursor - """ - first: Int - - """ - The number of items to return before the referenced "before" cursor - """ - last: Int - - """ - Cursor used along with the "first" argument to reference where in the dataset to get data - """ - after: String - - """ - Cursor used along with the "last" argument to reference where in the dataset to get data - """ - before: String - ): RefundToLineItemConnection - """ Object meta data """ @@ -24241,41 +24236,6 @@ enum RefundIdTypeEnum { ID } -""" -Connection between the Refund type and the LineItem type -""" -type RefundToLineItemConnection { - """ - Edges for the RefundToLineItemConnection connection - """ - edges: [RefundToLineItemConnectionEdge] - - """ - The nodes of the connection, without the edges - """ - nodes: [LineItem] - - """ - Information about pagination in a connection. - """ - pageInfo: WPPageInfo -} - -""" -An edge in a connection -""" -type RefundToLineItemConnectionEdge { - """ - A cursor for use in pagination - """ - cursor: String - - """ - The item at the end of the edge - """ - node: LineItem -} - """ Input for the registerCustomer mutation """ @@ -25827,11 +25787,41 @@ type RootQuery { """ discussionSettings: DiscussionSettings + """ + A simple product object + """ + externalProduct( + """ + The ID for identifying the ExternalProduct product + """ + id: ID + + """ + Type of ID being used identify product + """ + idType: ProductIdTypeEnum + ): ExternalProduct + """ Fields of the 'GeneralSettings' settings group """ generalSettings: GeneralSettings + """ + A simple product object + """ + groupedProduct( + """ + The ID for identifying the GroupProduct product + """ + id: ID + + """ + Type of ID being used identify product + """ + idType: ProductIdTypeEnum + ): GroupProduct + """ An object of the mediaItem Type. """ @@ -26826,6 +26816,21 @@ type RootQuery { before: String ): RootQueryToShippingMethodConnection + """ + A simple product object + """ + simpleProduct( + """ + The ID for identifying the SimpleProduct product + """ + id: ID + + """ + Type of ID being used identify product + """ + idType: ProductIdTypeEnum + ): SimpleProduct + """ A 0bject """ @@ -27121,6 +27126,21 @@ type RootQuery { where: RootQueryToUserConnectionWhereArgs ): RootQueryToUserConnection + """ + A simple product object + """ + variableProduct( + """ + The ID for identifying the VariableProduct product + """ + id: ID + + """ + Type of ID being used identify product + """ + idType: ProductIdTypeEnum + ): VariableProduct + """ Returns the current user """ diff --git a/framework/woocommerce/wp/queries/get-all-products-query.ts b/framework/woocommerce/wp/queries/get-all-products-query.ts index ef3400c4a..e7875e906 100644 --- a/framework/woocommerce/wp/queries/get-all-products-query.ts +++ b/framework/woocommerce/wp/queries/get-all-products-query.ts @@ -1,34 +1,22 @@ -export const productConnectionFragment = /* GraphQL */ ` - fragment productConnection on ProductConnection { - edges { - node { - id - name - image { - uri - altText +const getAllProductsQuery = /* GraphQL */ ` + query getAllProducts($first: Int = 250) { + products(first: $first) { + pageInfo { + hasNextPage + hasPreviousPage + } + edges { + node { + id + name + image { + uri + altText + } } } } - } } ` -const getAllProductsQuery = /* GraphQL */ ` -products(first: $first) { - pageInfo { - hasNextPage - hasPreviousPage - } - edges { - node { - id - name - ...productConnection - } - } -} - - ${productConnectionFragment} -` export default getAllProductsQuery