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

Any plans for GraphQL support? #963

Open
martinbonnin opened this issue Nov 22, 2024 · 4 comments
Open

Any plans for GraphQL support? #963

martinbonnin opened this issue Nov 22, 2024 · 4 comments

Comments

@martinbonnin
Copy link

DataFrame supports openAPI.

Are there any plans to support GraphQL schemas/operations to generate the models?

@koperagen
Copy link
Collaborator

koperagen commented Nov 22, 2024

Hi. We don't have such plans, but i can share why it might not be a problem and potential idea for the future.
For context, we develop a compiler plugin that reflects results of dataframe operations in types.
With its help it's easy to convert list of objects to DataFrame and have typed column access:
image
image

I wonder if this is good enough?

As for future, i probably didn't consider having a schema generator as a Gradle task. What i had in mind - in theory it can work like this

val api = ...
val df = api.executeDataFrameQuery("""
 query GetDogs {
    dogs {
      id
      breed
    }
  }
""")

df.dogs[0].id

or

val api = ...
val df = api.buildDataFrameQuery("""
  query Dog($breed: String!) {
    dog(breed: $breed) {
      id
      displayImage
    }
  }
""").execute("test")

So parse query at compile time, build types according to a schema and update return type. There's downside: generated types are local, so you can use them pretty much only in the same function where you execute this query. At the time i assumed that probably queries don't change that much, so even if we implement this idea, it might not be a significant developer experience improvement. For the time being it's too early to do something like this - we're not finished with "core" compiler plugin, but i'm curious to share the idea with you.

@martinbonnin
Copy link
Author

Thanks for sharing this! Looks definitely interesting!

There's downside: generated types are local, so you can use them pretty much only in the same function where you execute this query.

Not sure I follow there. Is there a compiler plugin limitation or so that would prevent making the generated types more broadly available?

In all cases, no rush from me, I just discovered DataFrame and was curious at the possibilities. Thanks for the super quick response!

@koperagen
Copy link
Collaborator

koperagen commented Nov 22, 2024

Is there a compiler plugin limitation

Yes. Because plugin wants to look at expressions, it needs to work at body analysis stage. It's too late to add any top-level declarations at that stage. As i understand, this is a fundamental compiler contract

@zaleslaw
Copy link
Collaborator

@martinbonnin not yet as @koperagen said, but we published one nice example with manual parsing https://blog.jetbrains.com/kotlin/2024/08/track-and-analyze-github-star-growth-with-kandy-and-kotlin-dataframe/#obtain-repository-stargazers-data-from-github

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

No branches or pull requests

3 participants