Zendro-dev / graphql-server

Skeleton NodeJS project for a graphQL server.
GNU General Public License v3.0
0 stars 1 forks source link

Possible bug in migration tool: executeGraphQL yields a "cannot read property 'headers' of null" #90

Closed asishallab closed 2 years ago

asishallab commented 2 years ago

When using our new migration method executeGraphQL the above error is generated.

Possibly the GraphQL context holding null for the request attribute is the cause?

Please write integration tests, reproducing this error and fix the tests.

Make sure all method of migration work, please

coeit commented 2 years ago

Error:

{
  "data": {
    "countAssays": null
  },
  "errors": [
    {
      "message": "Cannot read property 'headers' of null",
      "locations": [
        {
          "line": 1,
          "column": 2
        }
      ],
      "path": [
        "countAssays"
      ]
    }
  ]
}

Migration used:

"use strict";
const dict = require("../utils/graphql-sequelize-types");
const { Sequelize } = require("sequelize");
const { DOWN_MIGRATION } = require("../config/globals");
const fs = require("fs").promises;
/**
 * @module - Migrations to create or to drop a table correpondant to a sequelize model.
 */
module.exports = {
  /**
   * up - Creates a table with the fields specified in the the createTable function.
   *
   * @param  {object} zendro initialized zendro object
   */
  up: async (zendro) => {
    try {
      console.log("====UPLOAD DATA MIGRATION====")
      const countTest = await zendro.execute_graphql("{countAssays}") ;
      console.log(JSON.stringify(countTest,null,2));

    } catch (error) {
      console.error(error);
      throw Error(error);
    }
  },

  /**
   * down - Drop a table.
   *
   * @param  {object} zendro initialized zendro object
   */
  down: async (zendro) => {
    try {
    } catch (error) {
      throw new Error(error);
    }
  },
};