Skip to content

Commit 2176c4a

Browse files
committed
Fixing array and erros throws
1 parent 81e5910 commit 2176c4a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The `props` argument accepts the following fields:
7474

7575
| Key | Type | Default | Note |
7676
| --- | --- | --- | --- |
77-
| `typeDefs` | String | `null` | Contains GraphQL type definitions in [SDL](https://blog.graph.cool/graphql-sdl-schema-definition-language-6755bcb9ce51) or file path to type definitions (required if `schema` is not provided \*) |
77+
| `typeDefs` | `String` or `Function` or `DocumentNode` or `array` of previous | `null` | Contains GraphQL type definitions in [SDL](https://blog.graph.cool/graphql-sdl-schema-definition-language-6755bcb9ce51) or file path to type definitions (required if `schema` is not provided \*) |
7878
| `resolvers` | Object | `null` | Contains resolvers for the fields specified in `typeDefs` (required if `schema` is not provided \*) |
7979
| `schema` | Object | `null` | An instance of [`GraphQLSchema`](http://graphql.org/graphql-js/type/#graphqlschema) (required if `typeDefs` and `resolvers` are not provided \*) |
8080
| `context` | Object or Function | `{}` | Contains custom data being passed through your resolver chain. This can be passed in as an object, or as a Function with the signature `(req: ContextParameters) => any` \*\* |

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ function mergeTypeDefs(typeDefs: ITypeDefinitions): string {
304304
return print(typeDefs)
305305
}
306306

307-
return typeDefs.reduce<string>((acc, t) => acc + '\n' + mergeTypeDefs(t), '')
307+
if (Array.isArray(typeDefs)) {
308+
return typeDefs.reduce<string>((acc, t) => acc + '\n' + mergeTypeDefs(t), '')
309+
}
310+
311+
throw new Error('Typedef is not string, function, DocumentNode or array of previous')
308312
}
309313

310314
function isDocumentNode(node: any): node is DocumentNode {

0 commit comments

Comments
 (0)