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

Graphiql endpoints for tapir adapters #2379

Merged
merged 2 commits into from
Aug 31, 2024
Merged

Conversation

kyri-petrou
Copy link
Collaborator

/closes #2376

@calvinlfer was there something in the examples you wanted to add with graphiql?

@kyri-petrou kyri-petrou requested a review from ghostdogpr August 27, 2024 17:03
Comment on lines 230 to 235
.mapIn { segments =>
val uiPath = segments.mkString("/", "/", "")
Right(HttpUtils.graphiqlHtml(apiPath = apiPath0, uiPath = uiPath))
}(
_.value.split("/").filter(_.nonEmpty).toList
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does anyone think of a better way to do this? It works but I'm not too happy with this

Copy link
Owner

Choose a reason for hiding this comment

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

When is this even used?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean a less clean way but more efficient way would be to combine the steps into a single operation. But if it's not a hot path I wouldn't worry about it

Copy link
Contributor

@calvinlfer calvinlfer Aug 28, 2024

Choose a reason for hiding this comment

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

@ghostdogpr this would be used for the caliban-to-tapir adapter use case

im actually curious @kyri-petrou, would it be easier to expose the tapir data type itself (EndpointInput[Unit]) so you didn’t have to rebuild the path segment itself? Or is that exposing too much tapir details?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up reimplementing the endpoint properly, requiring an implicit MonadError (from sttp) to create it. It should be possible now to customize the endpoint using the .endpoint method on the ServerEndpoint.Full

@kyri-petrou kyri-petrou merged commit 35aa78e into series/2.x Aug 31, 2024
11 checks passed
@kyri-petrou kyri-petrou deleted the graphiql-tapir-endpoints branch August 31, 2024 11:19
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.

Support creating graphiql endpoints for tapir based adapters
4 participants