跳到正文
山月行
返回

源码分析

发布于更新于

源码

  1. 验证 Schema 的有效性
  2. 解析 Source(Operation)
  3. 执行
  • validateSchema
    • validateRootTypes
    • validateDirectives
    • validateTypes
  • parseSource
    • Source
    • Document
  • execute
    • rootType -> 可以从此获取到诸多 fields

执行 execute

  • execute
    • buildExecutionContext: 构建执行上下文信息,如 defaultResolver、operation 等
    • rootFields: 通过 获取到根路径的所有字段
    • executeOperation

Query

executeFields(exeContext, rootType, rootValue, path, rootFields);
  • executeFields
    • executeField
      • source, args, contextValue, info
      • resolvFn
      • completeValue

Mutation

executeFieldsSerially(exeContext, rootType, rootValue, path, rootFields);
  • executeFieldsSerially

Schema

  • GraphQLSchema

  • GraphQLObjectType

  • GraphQLDirective

  • isObjectType

  • schema.getQueryType()

  • schema.getMutationType()

  • schema.getSubscriptionType()

  • schema.getDirectives()


分享本文:

上一篇
使用 GraphQL 构建 web 应用
下一篇
利用 hash/query 键值对优化网络性能 (APQ)