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

Attempt graphql backend #71

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Attempt graphql backend #71

wants to merge 1 commit into from

Conversation

marcelldls
Copy link
Contributor

An additional "backend" for FastCS which provides a GraphQL api.
The API is fully discoverable and demoable from the autogenerated "GraphiQL gui" at "{domain}/graphql".
I choose to use the FastAPI "Strawberry" integration as it is the recommended library by FastAPI.

The following considersations have been taken to conform with best practices:

  • Attributes to be read using a query (also demonstates how subcontrollers are nested)

Example:

Query request:
query{
    DesiredPosition
    subcontroller {
        DesiredPosition
    }
}

Query response:
{
  "data": {
    "subcontroller": {
      "DesiredPosition": 1.0,
    }
    "DesiredPosition": 1.0,
  }
}
  • Attributes to be written using a mutation

Example:

Mutation request:
mutation{
  DesiredPosition(value: 2.0)
}

Mutation response:
{
  "data": {
    "DesiredPosition": 2.0
  }
}
  • Commands can cause server side effects so they are triggered using a mutation as per convention
    • A boolean response is returned to confirm the command was executed successfully

Example:

Mutation request:
mutation{
  BlinkLED
}

Mutation response:
{
  "data": {
    "BlinkLED": true
  }
}

Further:

  • I follow a similar pattern to the Tango "backend" to create the server and testing, so any feedback from the exisiting PRs should feed into this
  • I have added nested subcontrollers to test arbitrary subcontroller nesting as this is a harder problem for the graphql request structure - the tests of other backends should also apply this and need to be updated accordingly

@marcelldls marcelldls force-pushed the graphql-backend branch 3 times, most recently from 27035d9 to 7f5ced2 Compare November 12, 2024 09:05
@GDYendell
Copy link
Contributor

I have a had a quick look, but I am going to ignore this until we iterate on and merge some of the other recent PRs first, as you suggest.

@marcelldls
Copy link
Contributor Author

I have a had a quick look, but I am going to ignore this until we iterate on and merge some of the other recent PRs first, as you suggest.

Lets do that. When we are done iterating, we can enjoy some of the graph recursion xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants