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

Don't quote field names in object value strings #70

Merged
merged 1 commit into from
Nov 8, 2018

Conversation

edsrzf
Copy link
Contributor

@edsrzf edsrzf commented Nov 8, 2018

Doing this caused problems when introspecting default values in gqlgen.

For example, say you had this schema:

type Query {
  field(arg: Arg! = {argField: 1}): Int
}

input Arg {
  argField: Int
}

When introspecting, you'd get back results that looked like this:

{
   ...
   "args": [
     {
        name: "arg",
        defaultValue: "{\"argField\": 1}"
        ...
     }
   ]
   ...

The quotes around argField cause problems because they create invalid GraphQL input literal syntax.

Doing this caused problems when introspecting default values in gqlgen.

For example, say you had this schema:

```
type Query {
  field(arg: Arg! = {argField: 1}): Int
}

input Arg {
  argField: Int
}
```

When introspecting, you'd get back results that looked like this:

```
{
   ...
   "args": [
     {
        name: "arg",
        defaultValue: "{\"argField\": 1}"
        ...
     }
   ]
   ...
```

The quotes around `argField` cause problems because they create invalid
GraphQL input literal syntax.
@vektah
Copy link
Owner

vektah commented Nov 8, 2018

Nice find. Have you tested this in graphql playground to make sure it's can display with this format?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 90.834% when pulling ad58dda on edsrzf:fix-object-value-string into f119686 on vektah:master.

@edsrzf
Copy link
Contributor Author

edsrzf commented Nov 8, 2018

Yes, it works. The playground was what led to me discovering the problem in the first place, since the playground was complaining about invalid syntax in the default value.

@vektah vektah merged commit 07406bb into vektah:master Nov 8, 2018
@edsrzf edsrzf deleted the fix-object-value-string branch November 8, 2018 22:25
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