Skip to content

Improvements to GraphQL #2

@scottyeager

Description

@scottyeager

Currently we write something like this:

graphql.nodes(['nodeID'], power={'state_eq': 'Down'}, updatedAt_gt=int(1234.567))

Some aspects could be nicer:

  • We have a mix of quoted strings and unquoted keyword arg names
  • There's also a mix of keyword args and passing dicts for nested queries
  • It's possible to pass invalid names in some places with no error given, for example power={'state': 'Down'}
  • We must cast to the correct data type explicitly

Ideally we could:

from grid3.names import *
graphql.nodes([nodeID], power(state=Down), updatedAt_gt=1234.5678)

By implementing:

  • names contains variables with the same name as all possible strings used in gql queries (nodeID = 'nodeID', etc), as well as functions with the name of any nested parameters (power) that just return a simple data structure with their own name and any keyword args
  • Make _eq the default operator when none is specified (also check and reject invalid parameter names)
  • Automatically convert to the correct data type for the input (can derive this from the schema?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions