Skip to content

v0.12.0

Choose a tag to compare

@github-actions github-actions released this 01 Dec 01:11
· 71 commits to master since this release
8f229e3

Explicit null arguments. An explicit null can now reach a resolver, and a resolver can tell it apart from an omitted argument (#6):

  • The null literal is accepted, as in the specification, instead of being a syntax error. Unless Coercion is enabled, a resolver receives an explicit null as it receives an omitted value, so Args are unchanged for every query that worked before.
  • ResolveParams.ArgumentState reports whether an argument, or a value inside it such as p.ArgumentState("input", "description"), was omitted, sent as null or set. It works in every mode, even when a DefaultValue fills the argument. Use it to tell "clear this field" from "leave it unchanged".
  • SchemaConfig.Coercion controls ResolveParams.Args:
    • Legacy (default): Args are unchanged.
    • Spec: coerces as the specification and graphql-js do. An explicit null stays in Args as nil, including in an argument with a DefaultValue and inside input objects and lists.
    • Report: keeps the legacy Args and calls OnDifference wherever spec mode would behave differently: null dropped, null defaulted, default applied or null rejected.

Spec mode puts nil in Args for an explicit null, so a single-value type assertion such as p.Args["limit"].(int) panics. If your resolvers rely on that pattern, stay in legacy mode and use ArgumentState where you need it. Otherwise, run report mode first and fix the resolvers it points to before switching to spec. See Null and omitted arguments.

This builds on earlier work in graphql-go/graphql by xxlv (graphql-go/graphql#696), mpenick (graphql-go/graphql#536), evulse (graphql-go/graphql#401) and chirino (graphql-go/graphql#631).

Result.ErrorsJoined combines the errors of a result into one error with errors.Join, and errors.Is and errors.As reach the errors returned by resolvers (#71).

Guides. The documentation site has a migration guide and guides for objects and fields, interfaces and unions, enums, input objects and custom scalars.

What's Changed

Features

Documentation

  • docs: allow new cases in inherited table-driven tests by @seriallink in #90
  • docs: add a documentation site built with Hugo and Hextra by @seriallink in #89
  • docs: add the project logo and a richer home page to the site by @seriallink in #91
  • docs: replace the site footer with a single compact row by @seriallink in #92
  • docs: rewrite the documentation index and add a migration guide by @seriallink in #94
  • docs: add the Schema section and the objects and fields guide by @seriallink in #95
  • docs: add the interfaces and unions guide by @seriallink in #97
  • docs: add the enums guide by @seriallink in #99
  • docs: add the input objects guide by @seriallink in #103
  • docs: add the custom scalars guide by @seriallink in #104

Maintenance

New Contributors

  • @asxxb made their first contribution in #85

Full Changelog: v0.11.0...v0.12.0