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

Don't take selection input in getAvailableActions endpoint #706

Closed
wants to merge 1 commit into from

Conversation

georgefst
Copy link
Contributor

No description provided.

It's unnecessary, since the server already knows the selection. And when we flesh out the API, it will become necessary for clients to keep the server constantly informed of selection changes anyway. For example, the actions API is designed with the assumption that the selection state comes from the backend.

Since the request no longer contains a body, we are able to make it a `GET`.
@georgefst georgefst requested a review from a team October 3, 2022 13:29
{ OpenAPI.available = \level -> do
prog <- getProgram sid
case prog.progSelection of
Nothing -> pure []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone with just returning an empty list when there's no selection. I don't know that much would be gained by throwing an error.

Comment on lines 100 to +103
:> Summary "Get available actions for the definition, or a node within it"
:> QueryParam' '[Required, Strict] "level" Level
:> ReqBody '[JSON] Selection
:> OperationId "getAvailableActions"
:> Post '[JSON] [API.OfferedAction]
:> Get '[JSON] [API.OfferedAction]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps worth updating the Summary to mention "current selection"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, yes, of course.

Copy link
Contributor

@brprice brprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the code, but would like to discuss the approach further. In particular, I'm somewhat wary of making primer more stateful. It could well be the correct way to go, but I am missing the bigger picture at the moment. I think this would be good to discuss alongside your rework of the wider action API as that may clarify things.

@georgefst
Copy link
Contributor Author

We agreed in today's meeting that we'll continue to send the selection with every call, mostly in order to keep the backend more stateless.

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.

None yet

2 participants