question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'directives' of undefined at createFieldExecutionResolver

See original GitHub issue

Hi, it throws me the following error when trying to add directive resolve functions to the schema.

I have checked with forEachField and astNode is always undefined, is it my configuration or is it a bug?

const schema = new GraphQLSchema({
  directives: [
    new GraphQLDirective({
      name: 'isAuth',
      locations: [ DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.FIELD ]
    })
  ],
  query: new GraphQLObjectType({
    name: 'Query',
    fields: {
      user: {
        type: new GraphQLObjectType({
          name: 'User',
          fields: () => ({
            id: { type: GraphQLNonNull(GraphQLInt) },
            email: { type: GraphQLNonNull(GraphQLString) }
          })
        }),
        args: { id: { type: GraphQLInt } },
        resolve: (parent, args, context, info) => {
          return { id: 1, email: 'foo@gmail.com' };
        }
      }
    }
  })
});

const directiveResolvers = {
  isAuth(next, source, args, context, info) {
    throw Error('Ups!');
  }
};

const { addDirectiveResolveFunctionsToSchema } = require('graphql-directive');
addDirectiveResolveFunctionsToSchema(schema, directiveResolvers);

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Yunoocommented, Apr 2, 2018

I am facing the same problem while using graphql 0.13.2 with apollo-server-koa 1.3.4

0reactions
krisheskcommented, Aug 8, 2019

Hi there,

have you figured out why yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property of undefined, directive *ngIf, Angular 8
you can try this options (added an answer bc couldn't be able to edit the comment):. Opt1: <div *ngIf="userData?
Read more >
Schema Directives – GraphQL Tools
Everything you read below addresses some aspect of how a directive like @rename(to: ...) could be implemented. If that's not something you ...
Read more >
Relay directives | Martin Zlámal
Relay supports many (mostly) client-only directives which help you to describe your ... TypeError: Cannot read properties of undefined (reading 'length').
Read more >
Cannot read property 'subscribe' of undefined - ng-mocks
defaultMock in the case if the error has been caused by a mock component or a mock directive. Angular Material UI​. If you...
Read more >
Cannot Read Property “childNodes” Of Undefined In AngularJS
Ben Nadel demonstrates what may be causing a "TypeError: Cannot Read Property 'childNodes' Of Undefined " in your AngularJS application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found