AEB-labs/graphql-weaver

Cannot read property 'map' of undefined (link issue with undefined variableDefinitions)

Opened this issue · 0 comments

I'm not able to call link without getting the error "Cannot read property 'map' of undefined" in graphql-tools AddArgumentsAsVariables (in addVariablesToRootFields, which calls operation.variableDefinitions.map()).

The issue seems to originate from here -- https://github.com/AEB-labs/graphql-weaver/blob/master/src/pipeline/links.ts#L301 -- if I change undefined to [] that solves the error.

I've tried it with graphql-tools 4.0.0 (from your lock file) and 4.0.4 (the latest in 4.0) and get the same error in both. Quite honestly I don't know nearly enough about GraphQL query evaluation to understand what's causing this.

  const schema = await weaveSchemas({
    endpoints: [
      {
        namespace: 'account',
        typePrefix: 'Account',
        schema: auth0,
      },

      /* Wordpress post schemas */
      {
        namespace: 'blog',
        typePrefix: 'Blog',
        schema: createWordpressSchema('https://wp-int.codeday.org/graphql'),
        fieldMetadata: {
          'User.slug': {
            link: {
              field: 'account.user',
              argument: 'where.username',
              batchMode: false,
              linkFieldName: 'account',
            },
          },
        },
      },
    ]
  });

(auth0 is using makeExecutableSchema({ typeDefs, resolvers }); -- is there something special I'd need to do since it's not a remote schema?)