Skip to content
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

fix template error on generated defaults #146

Merged
merged 5 commits into from
Jun 26, 2018

Conversation

jonlundy
Copy link
Contributor

@jonlundy jonlundy commented Jun 22, 2018

See: #143 (comment)

The generated code doesn't separate default values with a comma. This adds a comma.

before:

		var tmp interface{} = map[string]interface{}{"offset": 0"limit": 25}

after:

		var tmp interface{} = map[string]interface{}{"offset": 0, "limit": 25}

fixes #144

@vektah
Copy link
Collaborator

vektah commented Jun 22, 2018

Thanks, you're cleaning up :)

This could use a test, maybe just a second arg in https://github.com/vektah/gqlgen/blob/master/example/scalars/schema.graphql#L3?

@@ -203,7 +203,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col
return graphql.Null
}
} else {
var tmp interface{} = map[string]interface{}{"location": "37,144", "isBanned": false}
var tmp interface{} = map[string]interface{}{"isBanned": false, "location": "37,144"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh-oh! I think the map is making this non deterministic. Probably needs a sort first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah looks like it would need a sort.

@vektah
Copy link
Collaborator

vektah commented Jun 26, 2018

Nice work

@vektah vektah merged commit e8c30ac into 99designs:master Jun 26, 2018
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
* fix template error on generated defaults

* go fmt

* add test for default fix

* .

* add key sort for default values
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.

map literal missing comma for query/edge attributes
2 participants