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

Scalar root field (string) only returns undefined #24

Closed
nikolasburk opened this issue Jan 11, 2018 · 4 comments
Closed

Scalar root field (string) only returns undefined #24

nikolasburk opened this issue Jan 11, 2018 · 4 comments
Assignees

Comments

@nikolasburk
Copy link
Contributor

What is the expected return value of a generated function on query when the root field is a scalar?

Consider this example:

const { makeExecutableSchema } = require('graphql-tools')
const { Binding } = require('graphql-binding')

const typeDefs = `
  type Query {
    hello(name: String): String
  }
`

const resolvers = {
  Query: {
    hello: (parent, { name }) => `Hello ${name || 'World'}`,
  },
}

const schema = makeExecutableSchema({ typeDefs, resolvers })

const helloWorldBinding = new Binding({
  schema,
})

helloWorldBinding.query.hello().then(result => console.log(result))

With the current implementation, it prints only undefined.

I'd expect this to print either Hello World or { hello : 'Hello World' }.

@marktani marktani added bug and removed bug labels Jan 11, 2018
@schickling
Copy link
Contributor

This definitely looks like a bug. We should also make sure to add some more test coverage for this.

@kbrandwijk kbrandwijk self-assigned this Jan 12, 2018
@kbrandwijk
Copy link
Contributor

I'm trying to debug this one. We have a separate issue for test coverage (#13)

@kbrandwijk
Copy link
Contributor

kbrandwijk commented Jan 12, 2018

It seems to have something to do with the way we create the info object.
Update: found the cause. This will be fixed in the next release.

kbrandwijk added a commit that referenced this issue Jan 12, 2018
The rootfield wasn't added to the info object if it is a scalas type.

Closes #24
@kbrandwijk
Copy link
Contributor

We should also make sure to add some more test coverage for this.

We actually had a test for this, but the assertion was incorrect.

kbrandwijk added a commit that referenced this issue Jan 12, 2018
The rootfield wasn't added to the info object if it is a scalas type.

Closes #24
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

No branches or pull requests

4 participants