-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from ghiscoding/feat/backend-service-features
feat(backend): add OData & GraphQL Service API interfaces - this will help user making sure they use valid options in their Backend Services - also add 2x new flags (useLocalFiltering & useLocalSorting) that could optionally be used with a backend service
- Loading branch information
Showing
31 changed files
with
553 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 29 additions & 12 deletions
41
src/aurelia-slickgrid/models/backendServiceApi.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,54 @@ | ||
import { OdataOption } from './odataOption.interface'; | ||
import { GraphqlResult } from './graphqlResult.interface'; | ||
import { BackendService } from './backendService.interface'; | ||
import { GraphqlServiceOption } from './graphqlServiceOption.interface'; | ||
import { GraphqlPaginatedResult } from './graphqlPaginatedResult.interface'; | ||
|
||
export interface BackendServiceApi { | ||
/** How long to wait until we start querying backend to avoid sending too many requests to backend server. Default to 750ms */ | ||
filterTypingDebounce?: number; | ||
|
||
/** Backend Service Options */ | ||
options?: OdataOption | GraphqlServiceOption; | ||
options?: any; | ||
|
||
/** Backend Service instance (could be OData or GraphQL Service) */ | ||
/** Backend Service instance (could be OData, GraphQL or any other Backend Service) */ | ||
service: BackendService; | ||
|
||
/** | ||
* Do we want to optionally use the local (in memory) filtering strategy? | ||
* This could be useful if user wishes to load the entire dataset only once with a OData/GraphQL Backend Service | ||
* and then use local filter strategy (with SlickGrid DataView) with only current local dataset (only what got loaded in memory). | ||
* This option could be used alone and/or with the "useLocalSorting" property. | ||
*/ | ||
useLocalFiltering?: boolean; | ||
|
||
/** | ||
* Do we want to optionally use the local (in memory) sorting strategy? | ||
* This could be useful if user wishes to load the entire dataset only once with a OData/GraphQL Backend Service | ||
* and then use local sorting strategy (with SlickGrid DataView) with only current local dataset (only what got loaded in memory). | ||
* This option could be used alone and/or with the "useLocalFiltering" property. | ||
*/ | ||
useLocalSorting?: boolean; | ||
|
||
// -- | ||
// available methods | ||
// ------------------ | ||
|
||
/** On error callback, when an error is thrown by the process execution */ | ||
onError?: (e: any) => void; | ||
|
||
/** On init (or on page load), what action to perform? */ | ||
onInit?: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult | any>; | ||
onInit?: (query: string) => Promise<any>; | ||
|
||
/** Before executing the query, what action to perform? For example, start a spinner */ | ||
preProcess?: () => void; | ||
|
||
/** On Processing, we get the query back from the service, and we need to provide a Promise. For example: this.http.get(myGraphqlUrl) */ | ||
process: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult | any>; | ||
process: (query: string) => Promise<any>; | ||
|
||
/** After executing the query, what action to perform? For example, stop the spinner */ | ||
postProcess?: (response: GraphqlResult | GraphqlPaginatedResult | any) => void; | ||
|
||
/** How long to wait until we start querying backend to avoid sending too many requests to backend server. Default to 750ms */ | ||
filterTypingDebounce?: number; | ||
postProcess?: (response: any) => void; | ||
|
||
/** | ||
* INTERNAL USAGE ONLY by Aurelia-Slickgrid | ||
* This internal process will be run just before postProcess and is meant to refresh the Dataset & Pagination after a GraphQL call | ||
*/ | ||
internalPostProcess?: (result: GraphqlResult | GraphqlPaginatedResult) => void; | ||
internalPostProcess?: (result: any) => void; | ||
} |
21 changes: 8 additions & 13 deletions
21
src/aurelia-slickgrid/models/backendServiceOption.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
import { BackendEventChanged } from './backendEventChanged.interface'; | ||
import { QueryArgument } from './queryArgument.interface'; | ||
import { Column } from './column.interface'; | ||
|
||
export interface BackendServiceOption { | ||
/** What is the dataset name, this is required for the GraphQL query to be built */ | ||
datasetName?: string; | ||
/** | ||
* @deprecated (no longer required since the service is always initialized with the grid object and we can get the column definitions from there) | ||
* Column definitions, used by the Backend Service to build the query according to the columns defined in the grid | ||
*/ | ||
columnDefinitions?: Column[]; | ||
|
||
/** Pagination options (itemsPerPage, pageSize, pageSizes) */ | ||
/** What are the pagination options? ex.: (first, last, offset) */ | ||
paginationOptions?: any; | ||
|
||
/** array of Filtering Options, ex.: [{ field: 'firstName', operator: 'EQ', value: 'John' }] */ | ||
filteringOptions?: any[]; | ||
|
||
/** array of Sorting Options, ex.: [{ field: 'firstName', direction: 'DESC' }] */ | ||
/** array of Filtering Options, ex.: [{ field: 'firstName', direction: 'DESC' }] */ | ||
sortingOptions?: any[]; | ||
|
||
/** Execute the process callback command on component init (page load) */ | ||
executeProcessCommandOnInit?: boolean; | ||
|
||
/** | ||
* Extra query arguments that be passed in addition to the default query arguments | ||
* For example in GraphQL, if we want to pass "userId" and we want the query to look like | ||
* users (first: 20, offset: 10, userId: 123) { ... } | ||
*/ | ||
extraQueryArguments?: QueryArgument[]; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/aurelia-slickgrid/models/graphqlServiceApi.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { BackendServiceApi } from './backendServiceApi.interface'; | ||
import { GraphqlResult } from './graphqlResult.interface'; | ||
import { GraphqlPaginatedResult } from './graphqlPaginatedResult.interface'; | ||
import { GraphqlServiceOption } from './graphqlServiceOption.interface'; | ||
import { GraphqlService } from '../services'; | ||
|
||
export interface GraphqlServiceApi extends BackendServiceApi { | ||
/** Backend Service Options */ | ||
options: GraphqlServiceOption; | ||
|
||
/** Backend Service instance (could be OData or GraphQL Service) */ | ||
service: GraphqlService; | ||
|
||
/** On init (or on page load), what action to perform? */ | ||
onInit?: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult>; | ||
|
||
/** On Processing, we get the query back from the service, and we need to provide a Promise. For example: this.http.get(myGraphqlUrl) */ | ||
process: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult>; | ||
|
||
/** After executing the query, what action to perform? For example, stop the spinner */ | ||
postProcess?: (response: GraphqlResult | GraphqlPaginatedResult) => void; | ||
|
||
/** | ||
* INTERNAL USAGE ONLY by Angular-Slickgrid | ||
* This internal process will be run just before postProcess and is meant to refresh the Dataset & Pagination after a GraphQL call | ||
*/ | ||
internalPostProcess?: (result: GraphqlResult | GraphqlPaginatedResult) => void; | ||
} |
Oops, something went wrong.