Skip to content

Commit

Permalink
feat(core): Create async job manager for long-running tasks
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `reindex` mutation now returns a JobInfo type, which has an id that can then be polled via the new `job` query as to its progress and status.

Relates to #111
  • Loading branch information
michaelbromley committed Jun 4, 2019
1 parent 325b807 commit a83945a
Show file tree
Hide file tree
Showing 16 changed files with 639 additions and 195 deletions.
191 changes: 113 additions & 78 deletions packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,29 @@ export type ImportInfo = {
imported: Scalars['Int'],
};

export type JobInfo = {
id: Scalars['String'],
name: Scalars['String'],
state: JobState,
progress: Scalars['Float'],
result?: Maybe<Scalars['JSON']>,
started?: Maybe<Scalars['DateTime']>,
ended?: Maybe<Scalars['DateTime']>,
duration?: Maybe<Scalars['Int']>,
};

export type JobListInput = {
state?: Maybe<JobState>,
ids?: Maybe<Array<Scalars['String']>>,
};

export enum JobState {
PENDING = 'PENDING',
RUNNING = 'RUNNING',
COMPLETED = 'COMPLETED',
FAILED = 'FAILED'
}


/** ISO 639-1 language code */
export enum LanguageCode {
Expand Down Expand Up @@ -1419,12 +1442,6 @@ export type Mutation = {
createChannel: Channel,
/** Update an existing Channel */
updateChannel: Channel,
/** Create a new Collection */
createCollection: Collection,
/** Update an existing Collection */
updateCollection: Collection,
/** Move a Collection to a different parent or index */
moveCollection: Collection,
/** Create a new Country */
createCountry: Country,
/** Update an existing Country */
Expand All @@ -1439,18 +1456,12 @@ export type Mutation = {
addCustomersToGroup: CustomerGroup,
/** Remove Customers from a CustomerGroup */
removeCustomersFromGroup: CustomerGroup,
/** Create a new Customer. If a password is provided, a new User will also be created an linked to the Customer. */
createCustomer: Customer,
/** Update an existing Customer */
updateCustomer: Customer,
/** Delete a Customer */
deleteCustomer: DeletionResponse,
/** Create a new Address and associate it with the Customer specified by customerId */
createCustomerAddress: Address,
/** Update an existing Address */
updateCustomerAddress: Address,
/** Update an existing Address */
deleteCustomerAddress: Scalars['Boolean'],
/** Create a new Collection */
createCollection: Collection,
/** Update an existing Collection */
updateCollection: Collection,
/** Move a Collection to a different parent or index */
moveCollection: Collection,
/** Create a new Facet */
createFacet: Facet,
/** Update an existing Facet */
Expand All @@ -1464,14 +1475,26 @@ export type Mutation = {
/** Delete one or more FacetValues */
deleteFacetValues: Array<DeletionResponse>,
updateGlobalSettings: GlobalSettings,
/** Create a new Customer. If a password is provided, a new User will also be created an linked to the Customer. */
createCustomer: Customer,
/** Update an existing Customer */
updateCustomer: Customer,
/** Delete a Customer */
deleteCustomer: DeletionResponse,
/** Create a new Address and associate it with the Customer specified by customerId */
createCustomerAddress: Address,
/** Update an existing Address */
updateCustomerAddress: Address,
/** Update an existing Address */
deleteCustomerAddress: Scalars['Boolean'],
importProducts?: Maybe<ImportInfo>,
/** Update an existing PaymentMethod */
updatePaymentMethod: PaymentMethod,
/** Create a new ProductOptionGroup */
createProductOptionGroup: ProductOptionGroup,
/** Update an existing ProductOptionGroup */
updateProductOptionGroup: ProductOptionGroup,
reindex: SearchReindexResponse,
reindex: JobInfo,
/** Create a new Product */
createProduct: Product,
/** Update an existing Product */
Expand Down Expand Up @@ -1556,21 +1579,6 @@ export type MutationUpdateChannelArgs = {
};


export type MutationCreateCollectionArgs = {
input: CreateCollectionInput
};


export type MutationUpdateCollectionArgs = {
input: UpdateCollectionInput
};


export type MutationMoveCollectionArgs = {
input: MoveCollectionInput
};


export type MutationCreateCountryArgs = {
input: CreateCountryInput
};
Expand Down Expand Up @@ -1608,35 +1616,18 @@ export type MutationRemoveCustomersFromGroupArgs = {
};


export type MutationCreateCustomerArgs = {
input: CreateCustomerInput,
password?: Maybe<Scalars['String']>
};


export type MutationUpdateCustomerArgs = {
input: UpdateCustomerInput
};


export type MutationDeleteCustomerArgs = {
id: Scalars['ID']
};


export type MutationCreateCustomerAddressArgs = {
customerId: Scalars['ID'],
input: CreateAddressInput
export type MutationCreateCollectionArgs = {
input: CreateCollectionInput
};


export type MutationUpdateCustomerAddressArgs = {
input: UpdateAddressInput
export type MutationUpdateCollectionArgs = {
input: UpdateCollectionInput
};


export type MutationDeleteCustomerAddressArgs = {
id: Scalars['ID']
export type MutationMoveCollectionArgs = {
input: MoveCollectionInput
};


Expand Down Expand Up @@ -1677,6 +1668,38 @@ export type MutationUpdateGlobalSettingsArgs = {
};


export type MutationCreateCustomerArgs = {
input: CreateCustomerInput,
password?: Maybe<Scalars['String']>
};


export type MutationUpdateCustomerArgs = {
input: UpdateCustomerInput
};


export type MutationDeleteCustomerArgs = {
id: Scalars['ID']
};


export type MutationCreateCustomerAddressArgs = {
customerId: Scalars['ID'],
input: CreateAddressInput
};


export type MutationUpdateCustomerAddressArgs = {
input: UpdateAddressInput
};


export type MutationDeleteCustomerAddressArgs = {
id: Scalars['ID']
};


export type MutationImportProductsArgs = {
csvFile: Scalars['Upload']
};
Expand Down Expand Up @@ -2281,20 +2304,22 @@ export type Query = {
channels: Array<Channel>,
channel?: Maybe<Channel>,
activeChannel: Channel,
collections: CollectionList,
collection?: Maybe<Collection>,
collectionFilters: Array<ConfigurableOperation>,
countries: CountryList,
country?: Maybe<Country>,
customerGroups: Array<CustomerGroup>,
customerGroup?: Maybe<CustomerGroup>,
customers: CustomerList,
customer?: Maybe<Customer>,
collections: CollectionList,
collection?: Maybe<Collection>,
collectionFilters: Array<ConfigurableOperation>,
facets: FacetList,
facet?: Maybe<Facet>,
globalSettings: GlobalSettings,
customers: CustomerList,
customer?: Maybe<Customer>,
order?: Maybe<Order>,
orders: OrderList,
job?: Maybe<JobInfo>,
jobs: Array<JobInfo>,
paymentMethods: PaymentMethodList,
paymentMethod?: Maybe<PaymentMethod>,
productOptionGroups: Array<ProductOptionGroup>,
Expand Down Expand Up @@ -2347,18 +2372,6 @@ export type QueryChannelArgs = {
};


export type QueryCollectionsArgs = {
languageCode?: Maybe<LanguageCode>,
options?: Maybe<CollectionListOptions>
};


export type QueryCollectionArgs = {
id: Scalars['ID'],
languageCode?: Maybe<LanguageCode>
};


export type QueryCountriesArgs = {
options?: Maybe<CountryListOptions>
};
Expand All @@ -2374,13 +2387,15 @@ export type QueryCustomerGroupArgs = {
};


export type QueryCustomersArgs = {
options?: Maybe<CustomerListOptions>
export type QueryCollectionsArgs = {
languageCode?: Maybe<LanguageCode>,
options?: Maybe<CollectionListOptions>
};


export type QueryCustomerArgs = {
id: Scalars['ID']
export type QueryCollectionArgs = {
id: Scalars['ID'],
languageCode?: Maybe<LanguageCode>
};


Expand All @@ -2396,6 +2411,16 @@ export type QueryFacetArgs = {
};


export type QueryCustomersArgs = {
options?: Maybe<CustomerListOptions>
};


export type QueryCustomerArgs = {
id: Scalars['ID']
};


export type QueryOrderArgs = {
id: Scalars['ID']
};
Expand All @@ -2406,6 +2431,16 @@ export type QueryOrdersArgs = {
};


export type QueryJobArgs = {
jobId: Scalars['String']
};


export type QueryJobsArgs = {
input?: Maybe<JobListInput>
};


export type QueryPaymentMethodsArgs = {
options?: Maybe<PaymentMethodListOptions>
};
Expand Down

0 comments on commit a83945a

Please sign in to comment.