Skip to content

TypeError: Cannot read property 'type' of undefined #142

Description

@engineersamuel

I have a valid Query that passes with tester.test however when I tester.mock with a fixture, then I'm seeing:

TypeError: Cannot read property 'type' of undefined
      at validateFixture (node_modules/easygraphql-tester/utils/fixture.js:50:27)
      at validateFixture (node_modules/easygraphql-tester/utils/fixture.js:100:19)

I debugged and it appears the issue is related to a simple name of type String which the mocker has no selectedType, hence the error at this line: https://github.com/EasyGraphQL/easygraphql-tester/blob/master/utils/fixture.js#L46

  if (schema[selectedType.type]) {

If I simply add a null check, all my tests pass:

  if (selectedType && schema[selectedType.type]) {

I'm happy to open a PR here, but I'd first want a core dev here to weigh in on what might be the issue and if this would be a valid check to simply add a null check on selectedType

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions