Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to GraphQL #2

Open
3 tasks
scottyeager opened this issue Nov 1, 2023 · 0 comments
Open
3 tasks

Improvements to GraphQL #2

scottyeager opened this issue Nov 1, 2023 · 0 comments

Comments

@scottyeager
Copy link
Collaborator

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?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant