У меня ошибка синтаксиса SQL в graphQL, когда я нажимаю на запрос с помощью join monster - PullRequest
0 голосов
/ 23 января 2019

Это моя схема

const graphql = require('graphql');
const joinMonster = require('join-monster');
const FilmDb  = require('../model/Films');
const { GraphQLObjectType, GraphQLList, GraphQLString, GraphQLInt,GraphQLSchema } = graphql;

const Films = new GraphQLObjectType({
  name: 'films',

  fields: () => ({
    id: {
        type: GraphQLInt,

      },

      name: {
          type: GraphQLString,

      },
  })
})
Films._typeConfig = {
    sqlTable: 'films',
    uniqueKey: 'id'
  }

const QueryRoot = new GraphQLObjectType({
  name: 'Query',
  fields: () => ({
    films: {
      type: new GraphQLList(Films),
      resolve: (parent, args, context, resolveInfo) => {
        return joinMonster.default(resolveInfo, {}, sql => {

            return FilmDb.query(sql).then(function(result) {

                return result;
              });

        })
      }
    }
  })
})

module.exports = new GraphQLSchema({
    query: QueryRoot
})

Когда я нажимаю на запрос ниже

{ фильмы { Я бы } }

Это показывает мне ошибку

{
  "errors": [
    {
      "message": "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.\"id\" AS \"id\"\nFROM films \"films\"' at line 1",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "films"
      ]
    }
  ],
  "data": {
    "films": null
  }
}

Мой SQL-запрос, генерируемый в терминале,

ВЫБРАТЬ "фильмы". "id" КАК "id" ИЗ фильмов "фильмы"

Здесь я использую nodejs, а в БД - Sequelize
В чем здесь ошибка ?? Я не могу найти точную ошибку.

...