SO Prisma GraphQL ошибка: упс. Похоже, внутренняя ошибка сервера - PullRequest
0 голосов
/ 15 октября 2019

Выполнение запроса для получения связанных таблиц не работает и отображает внутреннюю ошибку сервера.

Я несколько раз безуспешно пытался изменить схему datamodel.prisma.

Когда я выполняюэтот запрос:

{
  videos {
    id
    title
    sources {
      id
      quality
    }
  }
}

Возвращает эту ошибку:

{
  "data": {
    "videos": [
      {
        "id": "1",
        "title": "La peatonal del Vino",
        "sources": null
      },
      {
        "id": "2",
        "title": "Bodega Diamandes Exterior",
        "sources": null
      },
      {
        "id": "3",
        "title": "Con Boca",
        "sources": null
      },
      {
        "id": "4",
        "title": "Rep y el vino",
        "sources": null
      },
      {
        "id": "5",
        "title": "Pastel de chivo y ciruelas al bonarda acompañado con zapallos en manteca",
        "sources": null
      },
      {
        "id": "6",
        "title": "Séptimo Clericó",
        "sources": null
      },
      {
        "id": "7",
        "title": "Las ovejas de Kaiken",
        "sources": null
      },
      {
        "id": "8",
        "title": "Bodega Diamandes Exterior",
        "sources": null
      },
      {
        "id": "9",
        "title": "Capítulo Piloto",
        "sources": null
      }
    ]
  },
  "errors": [
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        0,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        1,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        2,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        3,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        4,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        5,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        6,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        7,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    },
    {
      "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck1s1nl7d001y0723idytrl5r",
      "path": [
        "videos",
        8,
        "sources"
      ],
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "requestId": "local:ck1s1nl7d001y0723idytrl5r"
    }
  ]
}

Это мой datamodel.prisma файл:

"""This is a custom built-in Scalar type from LightHouse. It handles Carbon dates"""
scalar DateTime @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")

type Channel {
    id: ID! @id
    title: String! @isUnique
    description: String!
    legend: String
    shownOnPremieres: Boolean!
    shownOnTheMostSeen: Boolean!
    shownOnExploreEverything: Boolean!
    videos: [Video!]!
    banner: Banner @relation(link: INLINE)
}

type Subtitle {
    id: ID! @id
    code: String!
    description: String!
    url: String!
    video: Video! @relation(link: INLINE)
}

type Source {
    id: ID! @id
    quality: String!
    url: String!
    video: Video! @relation(link: INLINE)
}

type Video {
    id: ID! @id
    title: String! @isUnique
    sources: [Source!]!
    thumb: String!
    duration: Int!
    description: String!
    legend: String!
    shownOnPremieres: Boolean!
    shownOnTheMostSeen: Boolean!
    shownOnExploreEverything: Boolean!
    channel: Channel! @relation(link: INLINE)
    subtitles: [Subtitle!]!
}

type Banner {
    id: ID! @id
    img: String! @isUnique
    duration: String!
    backgroundColor: String!
    buttonColor: String!
    textColor: String!
    channel: Channel!
}

type User {
    id: ID! @id
    name: String!
    email: String! @isUnique
    email_verified_at: DateTime
    password: String!
    remember_token: String!
    created_at: DateTime @created_at
    updated_at: DateTime @updated_at
}

Это вывод Prismaжурнал контейнера:

mmagni@mmagni-lenovo:/var/www/masvino/Server$ sudo docker-compose logs | grep ck1rxkct500rq072706my60la
[sudo] password for mmagni: 
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}
prisma_1  | {"key":"error/unhandled","requestId":"local:ck1rxkct500rq072706my60la","clientId":"default@default","payload":{"exception":"java.sql.SQLSyntaxErrorException: (conn=397) Unknown column 'RelationTable.channel' in 'field list'","query":"{\n  channels {\n    id\n    title\n    videos {\n      id\n      title\n    }\n  }\n}\n","variables":"{}","code":"0","stack_trace":"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:163)\\n org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:106)\\n org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:235)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:224)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)\\n org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:173)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$queryToDBIO$1(SharedSlickExtensions.scala:17)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"(conn=397) Unknown column 'RelationTable.channel' in 'field list'"}}

Что я могу сделать, чтобы получить этот ответ?

{
    "data": {
      "videos": [
        {
          "id": "1",
          "title": "La peatonal del Vino",
          "sources": [
            {
              "id": "1",
              "quality": "320p"
            },
            {
              "id": "2",
              "quality": "480p"
            },
            {
              "id": "3",
              "quality": "1080p"
            }
          ]
        },

        ...

      ]
    }
}

Я много чего пробовал безуспешно. Поле sources продолжает появляться null.

Ответы [ 2 ]

0 голосов
/ 17 октября 2019

Решением было выгрузить содержимое базы данных в файл резервной копии, удалить все таблицы в базе данных, повторно развернуть приложение prisma и импортировать файл резервной копии обратно в базу данных.

0 голосов
/ 16 октября 2019

Обновление

Ошибка говорит: «Неизвестный столбец RelationTable.channel. это должно быть связано с колонками и отношением. Может быть, попытаться сбросить вашу среду:

Попробуйте prisma export. Удалить вашу базу данных. и воссоздать с prisma deploy. Затем повторно загрузите свои данные с помощью prisma import

Старый ответ

Попробуйте добавить явное имя отношения между Source и Video в вашей модели данных.

type Source {
    id: ID! @id
    quality: String!
    url: String!
    video: Video! @relation(name: "VideoSource")
}

type Video {
    id: ID! @id
    title: String! @isUnique
    sources: [Source!]! @relation(name: "VideoSource")
    thumb: String!
    duration: Int!
    description: String!
    legend: String!
    shownOnPremieres: Boolean!
    shownOnTheMostSeen: Boolean!
    shownOnExploreEverything: Boolean!
    channel: Channel! @relation(link: INLINE)
    subtitles: [Subtitle!]!
}
...