Skip to content

Use Optional Types for GraphQL Optional #22

@maaft

Description

@maaft

With go 1.18 generics are now possible to use.

These can be used for example to implement the Optional concept:
https://github.com/frenchie4111/go-generic-optional

Although the current workaround with input_as_map works, we also have following issues:

  • When the order of arguments change for a GraphQL input object, we must migrate our existing code
  • When the variable-name order changes but the type order does not, we won't even notice this through our linter
  • auto-completion is not very good for function arguments

When instead we go back to structs but use the Optional concept from above package, we could have the best of both worlds:

  • no order dependencies
  • don't send optional values as nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions