graphql - 预期未定义为 GraphQL 叶类型

标签 graphql relayjs

在我的项目中运行中继编译器时出现以下错误

$ get-graphql-schema http://localhost/api/office > schema.graphql   
$ relay-compiler --src ./src/client --schema schema.graphql  
Watchman:  Watchman was not found in PATH.  See https://facebook.github.io/watchman/docs/install.html for installation instructions  
HINT: pass --watch to keep watching for changes.  

Writing js  
ERROR:  
Expected undefined to be a GraphQL leaf type.  
error Command failed with exit code 100.

有关如何调试此问题的任何建议,我的项目中最近的唯一更改(著名的遗言)是升级到中继 1.5。我怀疑 graphql 模式中的某些内容需要更改以适应新的中继编译器,但我没有看到它。

schema.graphql 如下:

schema {
  query: RootQuery
  mutation: RootMutation
}

type Delete {
  n: String
  nModified: String
  ok: String
}

type Room {
  _uuid: String
  roomName: String
  serviceName: String
  roomURL: String
  roomID: String
  phoneNumber1: String
  phoneNumber2: String
  participantCode: String
  moderatorCode: String
  video: String
  otherLink1: String
  otherLink2: String
  color: String
}

# Mutation interface
type RootMutation {
  createRoom(
    # Name of the room owner
    ownerName: String

    # Email of the room owner
    ownerEmail: String!

    # Name of the room
    roomName: String!

    # Service name
    serviceName: String!

    # URL
    roomURL: String!

    # ID to meeting room
    roomID: String

    # Phone number 1
    phoneNumber1: String!

    # Phone number 2
    phoneNumber2: String

    # Participant code
    participantCode: String!

    # Moderator code
    moderatorCode: String!

    # Video
    video: String

    # Color
    color: String
  ): Room
  deleteRoom(
    # Email of the room owner
    ownerEmail: String!

    # Name of the room
    roomName: String!
  ): Delete
}

type RootQuery {
  meetingsUser(ownerEmail: String!, _uuid: String, refetch: Boolean): [User]
}

type User {
  _id: String
  ownerEmail: String
  ownerName: String

  # Provides a list of all rooms owned by the user
  rooms: Room
}

最佳答案

这是因为您的类型缺少全局 id 字段。

我有同样的问题,但添加

type MyType = {
  id: ID
   ...
}

解决了问题。

另请参阅https://github.com/facebook/relay/issues/1880#issuecomment-307705428

关于graphql - 预期未定义为 GraphQL 叶类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49965663/

相关文章:

python - 使用 GraphQL +Ariadne + Flask 上传文件 : graphql. error.graphql_error.GraphQLError: 操作数据应该是 JSON 对象

reactjs - 在 Relay.js 中创建和删除根查询

reactjs - react 中继和 react Hook

javascript - 在 native 应用程序中使用中继

javascript - 使用中继js向前和向后分页

c# - GraphQL 为 .net 开发做好准备

javascript - 无法读取未定义的属性 'fetch'

javascript - Relay Modern - 如何在没有 fragmentContainer 的情况下使用 fetchQuery

javascript - GraphQL:获取部分字符串匹配

graphql - Graphcool 登录后更新中继存储