Skip to content

Support generating converters for all objects - #1236

Merged
schani merged 1 commit into
glideapps:masterfrom
benquarmby:converters
May 19, 2019
Merged

Support generating converters for all objects#1236
schani merged 1 commit into
glideapps:masterfrom
benquarmby:converters

Conversation

@benquarmby

Copy link
Copy Markdown
Contributor

Resolves #1235

@benquarmby benquarmby left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please consider this WIP for now. Would appreciate some input on the following:

  • Can the new converters option ship with just support for JS/TS/Flow? I don't have the expertise required for other languages.
  • I could use some guidance on how to write tests for this new behavior.
  • Any feedback on naming?


switch (this._jsOptions.converters) {
case ConvertersOptions.All:
this.forEachObject("interposing", converter);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

#naming-is-hard

Is All the right name for this? My assumption is this wont include enums?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to AllObjects.

import { EnumOption } from "../RendererOptions";

export enum ConvertersOptions {
Top = "top",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd call this TopLevel = "top-level".

@schani

schani commented May 18, 2019

Copy link
Copy Markdown
Member

Yes, this can ship with just JS/TS/Flow.

I left a comment on naming.

Right now the only easy test you can have is by adding the new option to the quickTestRendererOptions. When the quicktype tests run, all input files are tested with default options, but then a small subset of input files is also tested with all of the quickTestRendererOptions. In this case none of the additional generated code would run, but it would at least have to compile. To test more than that you'd have to write custom tests, for which we don't have a nice framework yet.

@schani

schani commented May 18, 2019

Copy link
Copy Markdown
Member

There are some differences in the output of GraphQL tests. Any idea why they happen?

@benquarmby

Copy link
Copy Markdown
Contributor Author

Will rename the TopLevel option and try out the quickTestRendererOptions.

Can't explain that diff. Will comb over the code changes again.

@benquarmby benquarmby left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed to rebase on top of master (and #1221) to fix the diff. All appears to be good now though.


switch (this._jsOptions.converters) {
case ConvertersOptions.All:
this.forEachObject("interposing", converter);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to AllObjects.

import { EnumOption } from "../RendererOptions";

export enum ConvertersOptions {
TopLevel = "top-level",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to TopLevel.

@schani
schani merged commit cc9151a into glideapps:master May 19, 2019
@schani

schani commented May 19, 2019

Copy link
Copy Markdown
Member

Fantastic, thank you!

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.

Create converters for all types, not just top level

2 participants