Skip to content

Commit generated code for tests to provide more information to reviewers #17

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

Merged
merged 1 commit into from
Sep 11, 2017

Conversation

dylanahsmith
Copy link
Contributor

Re: #12 (comment)

Problem

It is harder to see what effect changes to the generator has without seeing an example of what is generated.

Solution

We generate code as part of the test suite which we can check in to git to see a diff of changes to those files. This will make it easier to see what effect changes to the generator will have.

Copy link
Contributor

@BenEmdon BenEmdon 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!

@alinebee
Copy link

What should I be reviewing here? The generated sample code, or the fact that it is present in the repo?

@BenEmdon
Copy link
Contributor

The fact that it is present?

Copy link

@alinebee alinebee left a comment

Choose a reason for hiding this comment

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

In that case, 👍 to this being present!

I've flagged up an issue with how we handle date parsing, which has nothing to do with this PR but could be looked at separately.

guard let value = value as? String else {
throw SchemaViolationError(type: UnknownEntry.self, field: fieldName, value: fieldValue)
}
return iso8601DateParser.date(from: value)!

Choose a reason for hiding this comment

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

🚨 If the date string is in an unexpected format, this will cause our clients to die at runtime with a fatal error that is out of their control.

Instead, the date parsing could be rolled into the guard clause so that failure to parse becomes a SchemaViolationError as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code to serialize and deserialize a date string is specified to the generator, so this would only need to be improved for the example. It would be worth checking to see what we do for our shopify ios app though.

Choose a reason for hiding this comment

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

Looks like we use essentially the same code:

return GraphQL.iso8601DateParser.date(from: value)!

@dylanahsmith dylanahsmith merged commit 1ec6da3 into master Sep 11, 2017
@dylanahsmith dylanahsmith deleted the commit-generated-code branch September 11, 2017 14:55
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