小编Sca*_*ama的帖子

如何拆分很长的 GraphQL 模式

我正在尝试创建一个架构,但是会变得太长和混乱,拆分不同的查询、突变和输入的最佳实践是什么,这样我就可以只需要它们并组织它们以使其易于阅读。

我试图在网上查找信息,但没有任何明确的信息,我尽量不使用 Apollo。

const { buildSchema } = require('graphql');

module.exports = buildSchema(`
type Region {
  _id: ID!
  name: String!
  countries: [Country!]
}

type Country {
  _id: ID!
  name: String!
  region: [Region!]!
}

type City {
  _id: ID!
  name: String!
  country: [Country!]!
}

type Attraction {
  _id: ID!
  name: String!
  price: Float!
  description: String!
  city: [City!]!
}

type Eatery {
  _id: ID!
  name: String!
  cuisine: String!
  priceRange: String!
  location: [Location!]!
  typeOfEatery: String!
  city: [City!]!
}

type Location {
  _id: ID!
  latitude: …
Run Code Online (Sandbox Code Playgroud)

javascript graphql

15
推荐指数
1
解决办法
7616
查看次数

标签 统计

graphql ×1

javascript ×1