3

随着Graphcool被淘汰,我一直在尝试让react-adminFauna一起工作,但没有成功。Fauna GraphQL 语法与 Graphcool 不同,当然,当我连接到我的 Fauna DB 时,它无法识别任何资源。

如果我通过上传以下 GraphQL 模式来构建一个非常简单的 Fauna DB:

type Location {
    name: String!
    address1: String!
    address2: String
    city: String
    state: String
    zip: String
}

type Query {
  allLocations: [ Location ]
}

Fauna 创建的最终模式如下所示:

directive @embedded on OBJECT
directive @collection(name: String!) on OBJECT
directive @index(name: String!) on FIELD_DEFINITION
directive @resolver(
  name: String
  paginated: Boolean! = false
) on FIELD_DEFINITION
directive @relation(name: String) on FIELD_DEFINITION
directive @unique(index: String) on FIELD_DEFINITION
scalar Date

type Location {
  city: String
  name: String!
  zip: String
  state: String
  _id: ID!
  address2: String
  address1: String!
  _ts: Long!
}

input LocationInput {
  name: String!
  address1: String!
  address2: String
  city: String
  state: String
  zip: String
}

type LocationPage {
  data: [Location]!
  after: String
  before: String
}

scalar Long

type Mutation {
  createLocation(data: LocationInput!): Location!
  updateLocation(
    id: ID!
    data: LocationInput!
  ): Location
  deleteLocation(id: ID!): Location
}

type Query {
  findLocationByID(id: ID!): Location
  allLocations(
    _size: Int
    _cursor: String
  ): LocationPage!
}

scalar Time

我很难弄清楚如何调整 Graphcool/GraphQL 数据提供者来解决 Fauna 语法的差异。我注意到了几个不同之处:

  • Fauna 为 ID 命名_id,但 ra-data-graphcool 希望它们是id
  • 动物区系创建/更新突变需要一个反映类型的单个输入对象

Graphcool 数据提供者如何构建 gql 以获取记录列表也可能存在差异。有没有人为 Fauna 创建或修改过数据提供者(或者可能是 Back4App或其他免费/廉价的云 GraphQL 提供者)?

4

0 回答 0