Skip to content

Docs [3 of 4] #19

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

Closed
wants to merge 2 commits into from
Closed

Docs [3 of 4] #19

wants to merge 2 commits into from

Conversation

dbart01
Copy link
Contributor

@dbart01 dbart01 commented Sep 11, 2017

What this does

  • adds documentation comments for generated code
  • removes dead generated code
  • minor renames

// Generated from <%= script_name %>
//
// <%= type.name %>.swift
// Buy
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you adding Buy here?

}
<% end %>

override open func childObjectType(key: String) -> GraphQL.ChildObjectType {
Copy link
Contributor

Choose a reason for hiding this comment

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

These functions are used by the "Relay" layer of Shopify's ios app, so you can't remove them without breaking it right now.

@@ -221,9 +221,45 @@ def deserialize_value_code(field_name, expr, type, untyped: true)
raise NotImplementedError, "Unexpected #{type.kind} argument type"
end
end


def generate_input_init(type)
Copy link

Choose a reason for hiding this comment

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

Why move the template code into a function that builds a string? This seems like a step backwards in readability

text.gsub("\n", " ")
end

def input_field_description(type)
Copy link

Choose a reason for hiding this comment

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

This should be done at the ERB layer

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 reason it's done here is to avoid duplicating the logic across the whole .erb file.

"@available(*, deprecated#{message_argument})\n"
end

def swift_doc(element, include_args=true)
Copy link

Choose a reason for hiding this comment

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

Should also be at the ERB layer

def swift_arg_defs(field)
defs = ["aliasSuffix: String? = nil"]
defs = ["alias: String? = nil"]
Copy link

Choose a reason for hiding this comment

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

why this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

These "minor renames" are actually breaking changes. Also, the reason why it isn't just called alias is because we prefix what is passed in with the field name so that there aren't conflicts between fields. By just calling it alias it makes it sound like it is used literally as the GraphQL alias, which makes it seem like the caller needs to worry about preventing conflicts with other fields of the same name.

end

def swift_attributes(deprecatable)
return unless deprecatable.deprecated?
if deprecatable.deprecation_reason
message_argument = ", message:#{deprecatable.deprecation_reason.inspect}"
end
"@available(*, deprecated#{message_argument})"
"@available(*, deprecated#{message_argument})\n"
Copy link

Choose a reason for hiding this comment

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

why the addition of the \n? existing code seems to generate without this being necessary

// Generated from <%= script_name %>
//
// <%= schema_name %>.swift
// Buy
Copy link

Choose a reason for hiding this comment

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

not always the BUY SDK and idea was brought up in #14 (comment) for a solution

@@ -9,20 +34,19 @@ import Foundation
<% end %>

<% if type.interface? || type.union? %>
<%= %>
Copy link

Choose a reason for hiding this comment

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

what is this line for?

<% fields.each do |field| %>
<%= swift_attributes(field) %>
var <%= escape_reserved_word(field.camelize_name) %>: <%= swift_output_type(field.type) %> { get }
<% end %>
func childResponseObjectMap() -> [GraphQL.AbstractResponse]
Copy link

Choose a reason for hiding this comment

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

why the deletions?

@@ -192,6 +192,10 @@ public class GraphQL {
}
return key
}

internal func childResponseObjectMap() -> [GraphQL.AbstractResponse] {
Copy link

Choose a reason for hiding this comment

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

why are we introducing an abstract method that used to be defined at the protocol layer? why not leave as part of the protocol instead of having this one with the fatalError?

formatting nitpick: spaces instead of tabs here

text << "\n"
end
text << "}"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you just converted the code from the ERB file into a ruby method with string concatenation. I find the code more readable the way it was before. I also find PRs with miscellaneous changes like this a lot harder to review, since a refactor can hide functional changes.

doc << "\n"
doc << '/// - ' + arg.name + ': ' + (arg.description.nil? ? "No description" : format_arg_list(arg.description, 7))
end
doc << "\n///"
Copy link
Contributor

@dylanahsmith dylanahsmith Sep 12, 2017

Choose a reason for hiding this comment

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

Please follow the existing coding style. Specifically, here it looks like you are indenting with tabs instead of two spaces per indent

@dylanahsmith
Copy link
Contributor

Also, CI is 🔴

@dbart01 dbart01 closed this Sep 12, 2017
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