为什么每个GraphQL架构都有根查询和突变类型?

时间:2018-02-12 01:42:02

标签: graphql

为什么每个GraphQL架构都需要根querymutation类型?这似乎是不必要的样板。模式是否需要以不同方式编写?这个样板不应该是显而易见的吗?

schema {
  query:Query
  mutation:Mutation
}

1 个答案:

答案 0 :(得分:1)

我也是谷歌搜索,最后手动搜索有this comment的graphql-js源:

/**
 * GraphQL schema define root types for each type of operation. These types are
 * the same as any other type and can be named in any manner, however there is
 * a common naming convention:
 *
 *   schema {
 *     query: Query
 *     mutation: Mutation
 *   }
 *
 * When using this naming convention, the schema description can be omitted.
 */