为FaunaDB构建反应管理员数据提供者

时间:2020-03-28 15:04:50

标签: react-admin graphcool faunadb

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

如果我通过上传以下GraphQL模式来构建非常简单的动物区系数据库:

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提供程序)?

0 个答案:

没有答案