Skip to content

Conversation

gracenoah
Copy link
Contributor

This implementation is probably lax about where string descriptions are allowed. Additional test cases would be needed to verify the accuracy of the implementation. Also, this is backwards compatible with comment based descriptions and there's an option to disable the backwards compatibility.

fix #196
fix #147

@pavelnikolov
Copy link
Member

Thank you for your PR! I'll review it shortly!

@gracenoah
Copy link
Contributor Author

Thinking about this PR again this morning, I realize it's a real quick and dirty fix that works for my current use case, but in general is way too permissive. I'm thinking of improving it by splitting up Consume() from ConsumeDescription() instead of having a flag passed into the same function that consumes either one. That way I can significantly reduce the possible invalid schemas accepted. I think I was trying too hard to keep my changes only within the Consume() function and that led to a bad design. Feel free to review other PRs first. I'll let you know when I think this is in a mergable state.

@gracenoah gracenoah changed the title Parse string based descriptions [wip] Parse string based descriptions Oct 3, 2018
@gracenoah gracenoah changed the title [wip] Parse string based descriptions Parse string based descriptions Oct 3, 2018
@gracenoah
Copy link
Contributor Author

Updated. I think this is a bit more reasonable. I'm still not happy with the level of testing, but it did work with the new flag on in our codebase.

graphql.go Outdated
}

if err := s.schema.Parse(schemaString); err != nil {
if err := s.schema.Parse(schemaString, s.noCommentsAsDescriptions); err != nil {
Copy link
Member

@pavelnikolov pavelnikolov Oct 15, 2018

Choose a reason for hiding this comment

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

Should we name the variable useStringComments or some other shorter name instead? I think that shorter is better. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll rename it to useStringsAsDescriptions. The spec uses the term "description" so I prefer to use that here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, useStringDescriptions is as short as I can make it.

@Arachnid
Copy link

Is there anything preventing this from being merged? It'd be great to be able to load schemas with documentation in them.

@pavelnikolov
Copy link
Member

@Arachnid I'm sorry for the delay. I'm currently looking into subscriptions and then I'll get back to the remaining PRs - I think that tis name (i.e. noCommentsAsDescriptions) is too long. Otherwise, LGTM.

@gracenoah
Copy link
Contributor Author

Ready to merge if you are happy with it.

Copy link
Member

@pavelnikolov pavelnikolov left a comment

Choose a reason for hiding this comment

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

Apart from few simple things it looks good to me. Can you fix these, please?

l.descComment += "\n"
}

comment := ""
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer using the default value here instead of using an assignment:

var comment string

janflyborg added a commit to janflyborg/graphql-go that referenced this pull request Oct 16, 2018
@gracenoah
Copy link
Contributor Author

Sorry I haven't been responsive. I think I'll be able to get back to this next week.

@gracenoah
Copy link
Contributor Author

updated

@pavelnikolov pavelnikolov merged commit 940d2b0 into graph-gophers:master Oct 22, 2018
tinnywang pushed a commit to tinnywang/graphql-go that referenced this pull request Dec 13, 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.

Support for string literals as description Support latest syntax for descriptions

3 participants