vektah/gqlparser

Distribute prelude string over multiple lines

Closed this issue · 4 comments

Having one big long string literal in validator/prelude.go is a bit problematic. Foremostly it makes it hard to see what changes have been made in git history or blame. (I was trying to check if/when description: String field has been added to type __Schema.)

Is there any reason not to have it extend over multiple lines? (String literals joined with the + operator are combined into one literal at compile time, I believe.)

Perhaps even better would be to embed it (//go:embed), since go.mod is already at Go 1.16. (File embedding was added in 1.16.)

I see that there is already a prelude.graphqls file with the same text. It's redundant to have the same text committed twice. I'll fix it (embed the file) and generate a pull request.

Now that Go 1.16+ is widely adopted, embedding is now possible, so that would be a nice little cleanup. Thanks for noticing, and I'll look forward to your PR.

...I'll look forward to your PR.

#214

I just realised that prelude.go is generated, so the PR is incomplete. It needs to also obliterate all traces of inliner.go.

BTW generated files should have an initial comment // Code generated ... DO NOT EDIT.