Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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;
}
```