将带有附加参数的 graphql 运行 解析器

Will graphql run resolver with additional arguments

如果 graphql 查询模式是这样的:

user(user_id: Int): User

如果查询中的附加(电子邮件)参数未在查询模式中定义,apollo 运行 解析器会吗?

我想在解析器中迭代参数,但不确定是否可以污染它们。

P.S。如果有关于 apollo parcing 参数的文档,将不胜感激。

在 GraphQL 中,模式定义了客户端可用的字段,包括该字段可用的参数以及这些参数的类型。提交给 GraphQL 服务的任何查询都将在执行前先进行验证。如果查询包含任何无关的参数,它将无法通过验证并且不会被执行。这在规范中有解释 here

Formal Specification

  • For each argument in the document
  • Let argumentName be the Name of argument.
  • Let argumentDefinition be the argument definition provided by the parent field or definition named argumentName.
  • argumentDefinition must exist.

Explanatory Text

Every argument provided to a field or directive must be defined in the set of possible arguments of that field or directive.

为了更好地了解 GraphQL 的工作原理,我建议至少粗略地浏览一下规范。