Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type for typeDefs in GqlModuleOptions #53

Closed
michaelbromley opened this issue Sep 3, 2018 · 2 comments
Closed

Incorrect type for typeDefs in GqlModuleOptions #53

michaelbromley opened this issue Sep 3, 2018 · 2 comments

Comments

@michaelbromley
Copy link

I'm submitting a...


[ x ] Bug report

Current behavior

In the interface GqlModuleOptions, the typeDefs property is inherited from the apollo-server Config interface, which defines it as typeDefs?: DocumentNode | Array<DocumentNode>;

However, when I pass a DocumentNode as the value of typeDefs, I get the following error:

[Nest] 15752   - 2018-9-3 16:43:12   [ExceptionHandler] Syntax Error: Unexpected [ +102ms
Syntax Error: Unexpected [

GraphQL request (5:2)
4: }
5: ,[object Object]
    ^
6:         

    at syntaxError (C:\Development\vendure\vendure\server\node_modules\graphql\error\syntaxError.js:24:10)
    at unexpected (C:\Development\vendure\vendure\server\node_modules\graphql\language\parser.js:1485:33)
    at parseDefinition (C:\Development\vendure\vendure\server\node_modules\graphql\language\parser.js:160:9)
    at parseDocument (C:\Development\vendure\vendure\server\node_modules\graphql\language\parser.js:115:22)
    at parse (C:\Development\vendure\vendure\server\node_modules\graphql\language\parser.js:48:10)
    at parseDocument (C:\Development\vendure\vendure\server\node_modules\graphql-tag\src\index.js:129:16)
    at Object.gql (C:\Development\vendure\vendure\server\node_modules\graphql-tag\src\index.js:170:10)
    at GraphQLFactory.mergeOptions (C:\Development\vendure\vendure\server\node_modules\@nestjs\graphql\dist\graphql.factory.js:32:55)
    at Function.<anonymous> (C:\Development\vendure\vendure\server\node_modules\@nestjs\graphql\dist\graphql.module.js:73:55)
    at Generator.next (<anonymous>)

Passing a string representation of the schema on the other hand works, but then I need to cast the string to any to avoid type errors.

This line in the GraphQLFactory class seems to be the point that the value is used as a string (or array of strings to be exact):

typeDefs: gql`
${options.typeDefs}
`,

Expected behavior

Either the GraphQLFactory should perform a check to see if the typeDefs is a DocumentNode, and if so then skip the gql tag call.

Or just change the GqlModuleOptions to make typeDefs a string type.

Environment


Nest version: 5.3.0, graphql v5.1.0
@kamilmysliwiec
Copy link
Member

Fixed in v5.1.1. Thanks for reporting

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants