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

Fix object in default tag #192

Merged
merged 3 commits into from
Jun 6, 2018
Merged

Fix object in default tag #192

merged 3 commits into from
Jun 6, 2018

Conversation

miafoo
Copy link
Contributor

@miafoo miafoo commented Jun 1, 2018

This PR fixes 2 issues:

  • Default generator crashing when using objects as defaults (see example below).
  • Default spacing were inconsistent with everything else.

Example: In our API we've got something like:

users(
  query: String,
  orderBy: UserOrder = {field: creation_time, direction: ASC}
): [User!]!

However, using gql2ts breaks when trying to convert that, since orderBy is an object. This seems to fix it, although I'm not sure it's the best way to deal with it.

@coveralls
Copy link

coveralls commented Jun 1, 2018

Coverage Status

Coverage increased (+0.02%) to 96.379% when pulling 5d20eff on mikfoo:master into fb1cb87 on avantcredit:master.

@miafoo
Copy link
Contributor Author

miafoo commented Jun 1, 2018

Just noticed there's a PR for this already #186 although I guess this one also fixes the inconsistent default spacing.

Copy link
Contributor

@brettjurgens brettjurgens left a comment

Choose a reason for hiding this comment

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

looks good! thanks for opening a PR

@@ -7,7 +7,7 @@ import {

export interface IJSDocTag {
tag: string;
value: string;
value: string | Object;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use lowercase object?

const arr: Array<string | undefined> = [
fixDescriptionDocblock(description),
...tags.map(({ tag, value }) =>
`@${tag} ${typeof value === 'object' ? JSON.stringify(value) : value}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should just JSON.stringify everything, that way strings are quoted as well. What do you think?

Copy link
Contributor Author

@miafoo miafoo Jun 2, 2018

Choose a reason for hiding this comment

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

I'm pretty indifferent about it. I guess the main disadvantage with it is that it all looks like strings now, even numbers (not counting objects which looks like objects).

@brettjurgens
Copy link
Contributor

w/r/t spacing, it's recommended to run through Prettier (and language-typescript does this by default if installed). keeping track of spacing was a bit of a pain 😄

@miafoo
Copy link
Contributor Author

miafoo commented Jun 2, 2018

@brettjurgens I've updated the PR with the requested changes as well as commented on the JSON.stringify - check #192 (comment)

@brettjurgens brettjurgens merged commit 5ddac74 into amount:master Jun 6, 2018
@miafoo
Copy link
Contributor Author

miafoo commented Jun 6, 2018

@brettjurgens awesome, can you make a new NPM release as well?

@miafoo miafoo mentioned this pull request Jun 6, 2018
miafoo referenced this pull request in miafoo/gql2ts Jun 21, 2018
Fix object in default tag (#192)
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.

3 participants