Skip to content

How to suppress "Resolve function for "xyz" returned undefined" #107

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

Closed
tomitrescak opened this issue Aug 24, 2016 · 8 comments
Closed

How to suppress "Resolve function for "xyz" returned undefined" #107

tomitrescak opened this issue Aug 24, 2016 · 8 comments

Comments

@tomitrescak
Copy link

Is it possible? I don't care if that field is undefined.

Documentation says that I can enforce this behaviour with "forbidUndefinedInResolve", but I want opposite of that.

http://docs.apollostack.com/apollo-server/errors.html

@tomitrescak
Copy link
Author

tomitrescak commented Aug 24, 2016

I even set { allowUndefinedInResolve: true } in graphql options and no luck.

[EDIT] I see that these options are for the server 1.x. So how to suppress this in 2.x ?

@helfer
Copy link
Contributor

helfer commented Aug 24, 2016

For 0.2.0 you have to pass the option to makeExecutableSchema, which is a function from graphql-tools.

@helfer helfer closed this as completed Aug 24, 2016
@tomitrescak
Copy link
Author

Thanks for your answer!

Is there any documentation to graphql-tools? The documentation from Github points to old version of Apollo Server.

@helfer
Copy link
Contributor

helfer commented Aug 25, 2016

Right here: http://docs.apollostack.com/graphql-tools/generate-schema.html

On Wed, Aug 24, 2016 at 8:18 PM, Tomas Trescak [email protected]
wrote:

Thanks for your answer!

Is there any documentation to graphql-tools? The documentation from Github
points to old version of Apollo Server.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#107 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGQ__Iee3_Kyq5Dzbz2X2_22BuvtxGo8ks5qjQlqgaJpZM4Jrz8t
.

@payner35
Copy link

Here is what I got so far... https://github.com/payner35/reduxToast

But I'm still getting undefined errors

const executableSchema = makeExecutableSchema({
    typeDefs: Schema,
    resolvers: Resolvers,
    //connectors: Connectors,
});


createApolloServer({
    graphiql: true,
    pretty: true,
    schema: executableSchema,
    printErrors: true, // optional
    allowUndefinedInResolve: true // optional
});

@helfer
Copy link
Contributor

helfer commented Aug 28, 2016

@payner35 I'm pretty sure you have to pass that option to makeExecutableSchema, not into createApolloServer (which I assume is from meteor-integration).

@payner35
Copy link

payner35 commented Aug 28, 2016

Thanks @helfer .. working now

const executableSchema = makeExecutableSchema({
    typeDefs: Schema,
    resolvers: Resolvers,
    //connectors: Connectors,
    printErrors: true, // optional
    allowUndefinedInResolve: true // optional
});


createApolloServer({
    graphiql: true,
    pretty: true,
    schema: executableSchema
});

@mnpenner
Copy link

mnpenner commented Apr 7, 2017

@helfer I think the documentation is out of date. It still says forbidUndefinedInResolve is a function and you should use it to update your schema like so:

import { forbidUndefinedInResolve } from 'graphql-tools';

forbidUndefinedInResolve(schema); // TypeError: forbidUndefinedInResolve is not a function

Regardless, I can't get any errors to show. I'm trying

module.exports = makeExecutableSchema({
    typeDefs: schema,
    resolvers: require('./resolvers'),
    allowUndefinedInResolve: false,
    printErrors: true,
    logger: {
        log: err => {
            console.log(err);
        }
    },
});

And when I run I query I get back:

{"errors":[{"message":"Unknown operation named \"undefined\"."}]}

But no error is logged either to my terminal nor GraphiQL so I don't know what the issue is.

Edit: Nvm, that particular error appears to be a bug in GraphiQL, so Apollo never saw it. My logger is being hit now for other errors, although it's showing up twice now. Oh well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants