Skip to content

Default value as an object cause error#186

Open
izatop wants to merge 4 commits intoamount:masterfrom
izatop:default-value-error
Open

Default value as an object cause error#186
izatop wants to merge 4 commits intoamount:masterfrom
izatop:default-value-error

Conversation

@izatop
Copy link

@izatop izatop commented Apr 27, 2018

When GraphQL schema provides an object as a default value DEFAULT_DOCUMENTATION_GENERATOR throws error "cannot covert object to primitive value'. I've added JSON.stringify for that behavior.
Last try)

izatop added 4 commits April 27, 2018 17:12
When GraphQL schema provides an object as a default value
DEFAULT_DOCUMENTATION_GENERATOR throws error "cannor covert object
to primitive value'.
export const DEFAULT_DOCUMENTATION_GENERATOR: GenerateDocumentation = ({ description, tags = [] }) => (description || tags.length) ? `
/**
* ${filterAndJoinArray([fixDescriptionDocblock(description), ...tags.map(({ tag, value }) => `@${tag} ${value}`)], '\n* ')}
* ${filterAndJoinArray([fixDescriptionDocblock(description), ...tags.map(({ tag, value }) => `@${tag} ${typeof value === 'object' ? JSON.stringify(value) : value}`)], '\n* ')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just JSON.stringify everything, so then strings will be quoted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've add object check for it. But i don't know how fix snapshot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I meant was that I think we should just JSON.stringify instead of having the typecheck.

you should be able to fix the snapshot by running npm test -- -u

@miafoo miafoo mentioned this pull request Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants