Skip to content

Commit 1e1d412

Browse files
authored
Feature types changes (#4)
* Up * Added mocha.opts file with recursive param * Replaced chainable with resolvable * Added SimpleResolvable class * Fixed TS Errors on build Build error when `yarn build`: node_modules/@types/graphql/utilities/introspectionQuery.d.ts(96,13): error TS2456: Type alias 'IntrospectionTypeRef' circularly references itself. node_modules/@types/mocha/index.d.ts(19,16): error TS2694: Namespace 'Mocha' has no exported member 'Interface'. node_modules/@types/mocha/index.d.ts(25,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'reporter' must be of type 'any', but here has type 'string | ReporterConstructor'. node_modules/@types/mocha/index.d.ts(40,15): error TS2451: Cannot redeclare block-scoped variable 'mocha'. node_modules/@types/mocha/index.d.ts(41,15): error TS2451: Cannot redeclare block-scoped variable 'describe'. node_modules/@types/mocha/index.d.ts(42,15): error TS2451: Cannot redeclare block-scoped variable 'xdescribe'. node_modules/@types/mocha/index.d.ts(44,15): error TS2451: Cannot redeclare block-scoped variable 'context'. node_modules/@types/mocha/index.d.ts(46,15): error TS2451: Cannot redeclare block-scoped variable 'suite'. node_modules/@types/mocha/index.d.ts(47,15): error TS2451: Cannot redeclare block-scoped variable 'it'. node_modules/@types/mocha/index.d.ts(48,15): error TS2451: Cannot redeclare block-scoped variable 'xit'. node_modules/@types/mocha/index.d.ts(50,15): error TS2451: Cannot redeclare block-scoped variable 'test'. node_modules/@types/mocha/index.d.ts(51,15): error TS2451: Cannot redeclare block-scoped variable 'specify'. node_modules/@types/mocha/index.d.ts(56,6): error TS2300: Duplicate identifier 'MochaDone'. node_modules/@types/mocha/index.d.ts(75,15): error TS2300: Duplicate identifier 'Mocha'. node_modules/@types/mocha/index.d.ts(90,28): error TS2694: Namespace 'Mocha' has no exported member 'Interface'. node_modules/@types/mocha/index.d.ts(128,19): error TS2300: Duplicate identifier 'Mocha'. node_modules/@types/mocha/index.d.ts(332,5): error TS2300: Duplicate identifier 'export='. typings/globals/mocha/index.d.ts(29,13): error TS2451: Cannot redeclare block-scoped variable 'mocha'. typings/globals/mocha/index.d.ts(30,13): error TS2451: Cannot redeclare block-scoped variable 'describe'. typings/globals/mocha/index.d.ts(31,13): error TS2451: Cannot redeclare block-scoped variable 'xdescribe'. typings/globals/mocha/index.d.ts(33,13): error TS2451: Cannot redeclare block-scoped variable 'context'. typings/globals/mocha/index.d.ts(35,13): error TS2451: Cannot redeclare block-scoped variable 'suite'. typings/globals/mocha/index.d.ts(36,13): error TS2451: Cannot redeclare block-scoped variable 'it'. typings/globals/mocha/index.d.ts(37,13): error TS2451: Cannot redeclare block-scoped variable 'xit'. typings/globals/mocha/index.d.ts(39,13): error TS2451: Cannot redeclare block-scoped variable 'test'. typings/globals/mocha/index.d.ts(40,13): error TS2451: Cannot redeclare block-scoped variable 'specify'. typings/globals/mocha/index.d.ts(45,11): error TS2300: Duplicate identifier 'MochaDone'. typings/globals/mocha/index.d.ts(62,15): error TS2300: Duplicate identifier 'Mocha'. typings/globals/mocha/index.d.ts(110,19): error TS2300: Duplicate identifier 'Mocha'. typings/globals/mocha/index.d.ts(229,5): error TS2300: Duplicate identifier 'export='. * Updated Readme Added tests instruction and contributing section
1 parent 4cd868f commit 1e1d412

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3644
-519
lines changed

README.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# :shipit: graphql-resolved :shipit:
2-
`graphql-resolved` provides a **middleware**-like capability to your GraphQL servers by enabling the combination of multiple resolvers through a simple and expressive API.
2+
> Provides a **middleware**-like capability to your GraphQL api by enabling the combination of multiple resolvers through a simple and expressive API.
33
44
Resolvers solved :shipit:
55

66
[![NPM][npm-image]][npm-url]
77

88
[![Build Status][travis-image]][travis-url]
9+
[![npm version](https://badge.fury.io/js/graphql-resolved.svg)](https://badge.fury.io/js/graphql-resolved)
910

1011
[npm-url]: https://nodei.co/npm/graphql-resolved/
1112
[npm-image]: https://nodei.co/npm/graphql-resolved.png?downloads=true&downloadRank=true&stars=true
@@ -15,27 +16,26 @@ Resolvers solved :shipit:
1516

1617
## Installing
1718

18-
#### npm
19-
```
19+
```bash
2020
npm i graphql-resolved --save
2121
```
2222

23-
#### yarn
23+
##### or
2424

25-
```
25+
```bash
2626
yarn add graphql-resolved
2727
```
2828

2929
## Usage
3030
### Create your first resolver using the `chain`, `protect` or `apply` api
3131

32-
#### `chain` api
33-
34-
Create a new resolver chaining the ones in the supplied array. *The order matters from left to right*.
35-
The last resolver being the one return the final expect value.
32+
#### `chain`
33+
Return a resolver that is the sum of the ones in the supplied array.
34+
*The execution order follows the order from left to right*.
35+
The last resolver being the one to return the final expect value.
3636
```chain([1, 2, 3, 4])```
3737

38-
```javascript
38+
```ts
3939
import { chain } from 'graphql-resolved';
4040
import { isAuthenticated, isAdmin, isTopContributer } from './auth/resolvers';
4141
import * as UserResolvers from './user/resolvers';
@@ -51,23 +51,23 @@ const resolvers = {
5151
}
5252
```
5353

54-
#### `apply` api
55-
Applies all the `resolvers` to all of those in the `to` object.
56-
- `resolvers` (*The order matters from left to right*)
57-
```javascript
54+
#### `apply`
55+
Applies a list of `resolvers` to each of those supplied by the `to` object.
56+
- `resolvers` *The execution order follows the order from left to right*.
57+
```ts
5858
const allUserResolvers = apply({ resolvers: [isAuthenticated], to: UserResolvers })
5959
const Query = {
6060
...allUserResolvers
6161
}
6262
```
6363

64-
#### `protect` api
64+
#### `protect`
6565
The protect key work take three arguments:
6666
- `it` (Optional) a resolver function, if supplied `protect` returns a new resolver function
67-
- `all`(Optional) an object with resolvers, if supplied `protect` returns an object with the exact same resolvers names as keys
67+
- `all`(Optional) a map of resolvers, if supplied `protect` returns an object with the exact same resolvers names as keys
6868
- `using` a list of resolvers to apply(*The order matters from left to right*).
6969

70-
```javascript
70+
```ts
7171
const getMe = protect({
7272
it: UserResolvers.getMe,
7373
using: [isAuthenticated]
@@ -82,4 +82,24 @@ const Query = {
8282
getMe
8383
...adminResolvers
8484
}
85-
```
85+
```
86+
87+
## Tests
88+
89+
```bash
90+
npm test
91+
```
92+
93+
##### or
94+
95+
```bash
96+
yarn test
97+
```
98+
99+
## Contributing
100+
101+
Please feel free to drop an issue or propose a feature or pull request.
102+
103+
## License
104+
105+
MIT

dist/resolvers/Chainable.d.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/resolvers/Chainable.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

dist/resolvers/Chainable.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/resolvers/apis/apply.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResolversMap, Resolvers } from './../resolvers.types';
1+
import { ResolversMap, Resolvers } from './../types';
22
export interface ApplyArgs<R> {
33
resolvers: Resolvers;
44
to: ResolversMap;

dist/resolvers/apis/apply.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/resolvers/apis/apply.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/resolvers/apis/chain.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import { ResolverFunction, ChainedFunction } from './../resolvers.types';
2-
export declare const chain: <R>(resolvers: ResolverFunction<any>[]) => ChainedFunction<any> | ChainedFunction<R>;
1+
import { ResolverFunction, PureResolverFunction } from './../types';
2+
export declare const chain: <R = any>(resolvers: ResolverFunction<any>[]) => PureResolverFunction<R>;

dist/resolvers/apis/chain.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/resolvers/apis/chain.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)