Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schamane/grapqhl-defs
Definitions for graphql schemas
https://github.com/schamane/grapqhl-defs
definitions grapqhl npmjs schema
Last synced: 16 days ago
JSON representation
Definitions for graphql schemas
- Host: GitHub
- URL: https://github.com/schamane/grapqhl-defs
- Owner: schamane
- License: mit
- Created: 2021-08-30T19:28:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-11T10:54:47.000Z (over 2 years ago)
- Last Synced: 2023-03-11T23:46:48.827Z (almost 2 years ago)
- Topics: definitions, grapqhl, npmjs, schema
- Language: TypeScript
- Homepage:
- Size: 871 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Graphql Defs
## Use schema definitions
Add package to your project dependancies
```bash
npm i @schamane/graphql-defs
```Add exports to your shema index.ts
```typescript
export { SorterScalarSchema, FilterScalarSchema, FilterValueScalarSchema } from '@schamane/graphql-defs';
```## Example
Use Filters and Sorters with Query
```grapqhl
extend type Query {
testFilters(filters: [Filter], sort: Sorter): [FilterEntity]!
}
```Use it in your resolver implementation
```typescript
import { defaultSorter, Filter, Sorter } from '@schamane/graphql-defs';list(filters: Filter[], sort: Sorter): FilterEntity[] {
console.log(filters, sort);
if (sort) {
console.log('do sort', defaultSorter(this.data, sort));
return defaultSorter(this.data, sort);
}
return this.data;
}
```