Browse Source

feat(core): Channels mutation now returns PaginatedList

BREAKING CHANGE: The `channels` mutation now returns a PaginatedList rather than
a simple array of Channels.
Michael Bromley 2 years ago
parent
commit
d7a344703b

+ 43 - 1
packages/asset-server-plugin/e2e/graphql/generated-e2e-asset-server-plugin-types.ts

@@ -379,6 +379,44 @@ export type ChannelDefaultLanguageError = ErrorResult & {
     message: Scalars['String'];
 };
 
+export type ChannelFilterParameter = {
+    code?: InputMaybe<StringOperators>;
+    createdAt?: InputMaybe<DateOperators>;
+    currencyCode?: InputMaybe<StringOperators>;
+    defaultCurrencyCode?: InputMaybe<StringOperators>;
+    defaultLanguageCode?: InputMaybe<StringOperators>;
+    id?: InputMaybe<IdOperators>;
+    pricesIncludeTax?: InputMaybe<BooleanOperators>;
+    token?: InputMaybe<StringOperators>;
+    updatedAt?: InputMaybe<DateOperators>;
+};
+
+export type ChannelList = PaginatedList & {
+    items: Array<Channel>;
+    totalItems: Scalars['Int'];
+};
+
+export type ChannelListOptions = {
+    /** Allows the results to be filtered */
+    filter?: InputMaybe<ChannelFilterParameter>;
+    /** Specifies whether multiple "filter" arguments should be combines with a logical AND or OR operation. Defaults to AND. */
+    filterOperator?: InputMaybe<LogicalOperator>;
+    /** Skips the first n results, for use in pagination */
+    skip?: InputMaybe<Scalars['Int']>;
+    /** Specifies which properties to sort the results by */
+    sort?: InputMaybe<ChannelSortParameter>;
+    /** Takes n results, for use in pagination */
+    take?: InputMaybe<Scalars['Int']>;
+};
+
+export type ChannelSortParameter = {
+    code?: InputMaybe<SortOrder>;
+    createdAt?: InputMaybe<SortOrder>;
+    id?: InputMaybe<SortOrder>;
+    token?: InputMaybe<SortOrder>;
+    updatedAt?: InputMaybe<SortOrder>;
+};
+
 export type Collection = Node & {
     assets: Array<Asset>;
     breadcrumbs: Array<CollectionBreadcrumb>;
@@ -4383,7 +4421,7 @@ export type Query = {
     /** Get a list of Assets */
     assets: AssetList;
     channel?: Maybe<Channel>;
-    channels: Array<Channel>;
+    channels: ChannelList;
     /** Get a Collection either by id or slug. If neither id nor slug is specified, an error will result. */
     collection?: Maybe<Collection>;
     collectionFilters: Array<ConfigurableOperationDefinition>;
@@ -4475,6 +4513,10 @@ export type QueryChannelArgs = {
     id: Scalars['ID'];
 };
 
+export type QueryChannelsArgs = {
+    options?: InputMaybe<ChannelListOptions>;
+};
+
 export type QueryCollectionArgs = {
     id?: InputMaybe<Scalars['ID']>;
     slug?: InputMaybe<Scalars['String']>;

+ 45 - 1
packages/common/src/generated-types.ts

@@ -375,6 +375,45 @@ export type ChannelDefaultLanguageError = ErrorResult & {
   message: Scalars['String'];
 };
 
+export type ChannelFilterParameter = {
+  code?: InputMaybe<StringOperators>;
+  createdAt?: InputMaybe<DateOperators>;
+  currencyCode?: InputMaybe<StringOperators>;
+  defaultCurrencyCode?: InputMaybe<StringOperators>;
+  defaultLanguageCode?: InputMaybe<StringOperators>;
+  id?: InputMaybe<IdOperators>;
+  pricesIncludeTax?: InputMaybe<BooleanOperators>;
+  token?: InputMaybe<StringOperators>;
+  updatedAt?: InputMaybe<DateOperators>;
+};
+
+export type ChannelList = PaginatedList & {
+  __typename?: 'ChannelList';
+  items: Array<Channel>;
+  totalItems: Scalars['Int'];
+};
+
+export type ChannelListOptions = {
+  /** Allows the results to be filtered */
+  filter?: InputMaybe<ChannelFilterParameter>;
+  /** Specifies whether multiple "filter" arguments should be combines with a logical AND or OR operation. Defaults to AND. */
+  filterOperator?: InputMaybe<LogicalOperator>;
+  /** Skips the first n results, for use in pagination */
+  skip?: InputMaybe<Scalars['Int']>;
+  /** Specifies which properties to sort the results by */
+  sort?: InputMaybe<ChannelSortParameter>;
+  /** Takes n results, for use in pagination */
+  take?: InputMaybe<Scalars['Int']>;
+};
+
+export type ChannelSortParameter = {
+  code?: InputMaybe<SortOrder>;
+  createdAt?: InputMaybe<SortOrder>;
+  id?: InputMaybe<SortOrder>;
+  token?: InputMaybe<SortOrder>;
+  updatedAt?: InputMaybe<SortOrder>;
+};
+
 export type Collection = Node & {
   __typename?: 'Collection';
   assets: Array<Asset>;
@@ -4611,7 +4650,7 @@ export type Query = {
   /** Get a list of Assets */
   assets: AssetList;
   channel?: Maybe<Channel>;
-  channels: Array<Channel>;
+  channels: ChannelList;
   /** Get a Collection either by id or slug. If neither id nor slug is specified, an error will result. */
   collection?: Maybe<Collection>;
   collectionFilters: Array<ConfigurableOperationDefinition>;
@@ -4709,6 +4748,11 @@ export type QueryChannelArgs = {
 };
 
 
+export type QueryChannelsArgs = {
+  options?: InputMaybe<ChannelListOptions>;
+};
+
+
 export type QueryCollectionArgs = {
   id?: InputMaybe<Scalars['ID']>;
   slug?: InputMaybe<Scalars['String']>;

File diff suppressed because it is too large
+ 577 - 520
packages/core/e2e/graphql/generated-e2e-admin-types.ts


+ 5 - 3
packages/core/e2e/graphql/shared-definitions.ts

@@ -1006,9 +1006,11 @@ export const DELETE_PROMOTION = gql`
 export const GET_CHANNELS = gql`
     query GetChannels {
         channels {
-            id
-            code
-            token
+            items {
+                id
+                code
+                token
+            }
         }
     }
 `;

+ 7 - 3
packages/core/src/api/resolvers/admin/channel.resolver.ts

@@ -7,8 +7,10 @@ import {
     MutationUpdateChannelArgs,
     Permission,
     QueryChannelArgs,
+    QueryChannelsArgs,
     UpdateChannelResult,
 } from '@vendure/common/lib/generated-types';
+import { PaginatedList } from '@vendure/common/lib/shared-types';
 
 import { ErrorResultUnion, isGraphQlErrorResult } from '../../../common/error/error-result';
 import { Channel } from '../../../entity/channel/channel.entity';
@@ -25,9 +27,11 @@ export class ChannelResolver {
 
     @Query()
     @Allow(Permission.ReadSettings, Permission.ReadChannel)
-    async channels(@Ctx() ctx: RequestContext): Promise<Channel[]> {
-        const { items } = await this.channelService.findAll(ctx);
-        return items
+    async channels(
+        @Ctx() ctx: RequestContext,
+        @Args() args: QueryChannelsArgs,
+    ): Promise<PaginatedList<Channel>> {
+        return this.channelService.findAll(ctx, args.options || undefined);
     }
 
     @Query()

+ 8 - 1
packages/core/src/api/schema/admin-api/channel.api.graphql

@@ -1,5 +1,5 @@
 type Query {
-    channels: [Channel!]!
+    channels(options: ChannelListOptions): ChannelList!
     channel(id: ID!): Channel
     activeChannel: Channel!
 }
@@ -15,6 +15,13 @@ type Mutation {
     deleteChannel(id: ID!): DeletionResponse!
 }
 
+type ChannelList implements PaginatedList {
+    items: [Channel!]!
+    totalItems: Int!
+}
+
+input ChannelListOptions
+
 input CreateChannelInput {
     code: String!
     token: String!

+ 43 - 1
packages/elasticsearch-plugin/e2e/graphql/generated-e2e-elasticsearch-plugin-types.ts

@@ -379,6 +379,44 @@ export type ChannelDefaultLanguageError = ErrorResult & {
     message: Scalars['String'];
 };
 
+export type ChannelFilterParameter = {
+    code?: InputMaybe<StringOperators>;
+    createdAt?: InputMaybe<DateOperators>;
+    currencyCode?: InputMaybe<StringOperators>;
+    defaultCurrencyCode?: InputMaybe<StringOperators>;
+    defaultLanguageCode?: InputMaybe<StringOperators>;
+    id?: InputMaybe<IdOperators>;
+    pricesIncludeTax?: InputMaybe<BooleanOperators>;
+    token?: InputMaybe<StringOperators>;
+    updatedAt?: InputMaybe<DateOperators>;
+};
+
+export type ChannelList = PaginatedList & {
+    items: Array<Channel>;
+    totalItems: Scalars['Int'];
+};
+
+export type ChannelListOptions = {
+    /** Allows the results to be filtered */
+    filter?: InputMaybe<ChannelFilterParameter>;
+    /** Specifies whether multiple "filter" arguments should be combines with a logical AND or OR operation. Defaults to AND. */
+    filterOperator?: InputMaybe<LogicalOperator>;
+    /** Skips the first n results, for use in pagination */
+    skip?: InputMaybe<Scalars['Int']>;
+    /** Specifies which properties to sort the results by */
+    sort?: InputMaybe<ChannelSortParameter>;
+    /** Takes n results, for use in pagination */
+    take?: InputMaybe<Scalars['Int']>;
+};
+
+export type ChannelSortParameter = {
+    code?: InputMaybe<SortOrder>;
+    createdAt?: InputMaybe<SortOrder>;
+    id?: InputMaybe<SortOrder>;
+    token?: InputMaybe<SortOrder>;
+    updatedAt?: InputMaybe<SortOrder>;
+};
+
 export type Collection = Node & {
     assets: Array<Asset>;
     breadcrumbs: Array<CollectionBreadcrumb>;
@@ -4383,7 +4421,7 @@ export type Query = {
     /** Get a list of Assets */
     assets: AssetList;
     channel?: Maybe<Channel>;
-    channels: Array<Channel>;
+    channels: ChannelList;
     /** Get a Collection either by id or slug. If neither id nor slug is specified, an error will result. */
     collection?: Maybe<Collection>;
     collectionFilters: Array<ConfigurableOperationDefinition>;
@@ -4475,6 +4513,10 @@ export type QueryChannelArgs = {
     id: Scalars['ID'];
 };
 
+export type QueryChannelsArgs = {
+    options?: InputMaybe<ChannelListOptions>;
+};
+
 export type QueryCollectionArgs = {
     id?: InputMaybe<Scalars['ID']>;
     slug?: InputMaybe<Scalars['String']>;

+ 43 - 1
packages/payments-plugin/e2e/graphql/generated-admin-types.ts

@@ -379,6 +379,44 @@ export type ChannelDefaultLanguageError = ErrorResult & {
     message: Scalars['String'];
 };
 
+export type ChannelFilterParameter = {
+    code?: InputMaybe<StringOperators>;
+    createdAt?: InputMaybe<DateOperators>;
+    currencyCode?: InputMaybe<StringOperators>;
+    defaultCurrencyCode?: InputMaybe<StringOperators>;
+    defaultLanguageCode?: InputMaybe<StringOperators>;
+    id?: InputMaybe<IdOperators>;
+    pricesIncludeTax?: InputMaybe<BooleanOperators>;
+    token?: InputMaybe<StringOperators>;
+    updatedAt?: InputMaybe<DateOperators>;
+};
+
+export type ChannelList = PaginatedList & {
+    items: Array<Channel>;
+    totalItems: Scalars['Int'];
+};
+
+export type ChannelListOptions = {
+    /** Allows the results to be filtered */
+    filter?: InputMaybe<ChannelFilterParameter>;
+    /** Specifies whether multiple "filter" arguments should be combines with a logical AND or OR operation. Defaults to AND. */
+    filterOperator?: InputMaybe<LogicalOperator>;
+    /** Skips the first n results, for use in pagination */
+    skip?: InputMaybe<Scalars['Int']>;
+    /** Specifies which properties to sort the results by */
+    sort?: InputMaybe<ChannelSortParameter>;
+    /** Takes n results, for use in pagination */
+    take?: InputMaybe<Scalars['Int']>;
+};
+
+export type ChannelSortParameter = {
+    code?: InputMaybe<SortOrder>;
+    createdAt?: InputMaybe<SortOrder>;
+    id?: InputMaybe<SortOrder>;
+    token?: InputMaybe<SortOrder>;
+    updatedAt?: InputMaybe<SortOrder>;
+};
+
 export type Collection = Node & {
     assets: Array<Asset>;
     breadcrumbs: Array<CollectionBreadcrumb>;
@@ -4383,7 +4421,7 @@ export type Query = {
     /** Get a list of Assets */
     assets: AssetList;
     channel?: Maybe<Channel>;
-    channels: Array<Channel>;
+    channels: ChannelList;
     /** Get a Collection either by id or slug. If neither id nor slug is specified, an error will result. */
     collection?: Maybe<Collection>;
     collectionFilters: Array<ConfigurableOperationDefinition>;
@@ -4475,6 +4513,10 @@ export type QueryChannelArgs = {
     id: Scalars['ID'];
 };
 
+export type QueryChannelsArgs = {
+    options?: InputMaybe<ChannelListOptions>;
+};
+
 export type QueryCollectionArgs = {
     id?: InputMaybe<Scalars['ID']>;
     slug?: InputMaybe<Scalars['String']>;

File diff suppressed because it is too large
+ 0 - 0
schema-admin.json


Some files were not shown because too many files changed in this diff