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

Adds an AddFieldConfig method to InputObjects #332

Merged
merged 2 commits into from
Jul 19, 2018
Merged

Adds an AddFieldConfig method to InputObjects #332

merged 2 commits into from
Jul 19, 2018

Conversation

robdaemon
Copy link
Contributor

Thunks don't always work for adding self-referential fields
to an InputObject.

Example:

inputObj := graphql.NewInputObject(graphql.InputObjectConfig{
    Name: "MyObject",
    Fields: (graphql.InputObjectConfigFieldMapThunk)(func() graphql.InputObjectConfigFieldMap {
        return graphql.InputObjectConfigFieldMap{
            "parent": &graphql.InputObjectFieldConfig{
                Type: inputObj,
            },
        }
    }),
})

Go does not this definition, but you can work around this with AddFieldConfig.

This makes an InputObject work like other Object types.

Thunks don't always work for adding self-referential fields
to an InputObject.

Example:

```
inputObj := graphql.NewInputObject(graphql.InputObjectConfig{
    Name: "MyObject",
    Fields: (graphql.InputObjectConfigFieldMapThunk)(func() graphql.InputObjectConfigFieldMap {
        return graphql.InputObjectConfigFieldMap{
            "parent": &graphql.InputObjectFieldConfig{
                Type: inputObj,
            },
        }
    }),
})
```

Go does not this definition, but you can work around this with AddFieldConfig.

This makes an InputObject work like other Object types.
@coveralls
Copy link

coveralls commented Jun 11, 2018

Coverage Status

Coverage decreased (-0.06%) to 91.74% when pulling a05d5bb on robdaemon:add_inputobject_field into 83f0349 on graphql-go:master.

@chris-ramon chris-ramon reopened this Jul 19, 2018
@chris-ramon
Copy link
Member

LGTM 👍 — thanks a lot @robdaemon

@chris-ramon chris-ramon merged commit 086b3bf into graphql-go:master Jul 19, 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.

3 participants