-
Notifications
You must be signed in to change notification settings - Fork 645
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
[compiler] Add GraphQL AST to Apollo Compiler Plugins #5709
Comments
@StylianosGakis I gave a shot as generating visitors for all Call
public fun interface Visitor {
public fun visit(`data`: Any?, block: (FlowStep) -> Unit)
}
public val generatedVisitors: Map<String, Visitor> = mapOf(
"getFlow" to Visitor { data, block ->
data as GetFlowQuery.Data
data.flowClaimBarNext.cast<FlowStep>().maybe(block)
},
"getNestedFlow" to Visitor { data, block ->
data as GetNestedFlowQuery.Data
data.nested?.flows?.forEach {
it?.cast<FlowStep>().maybe(block)
}
},
)
TBH, it's quite the setup to avoid a bunch of manual boilerplate (related xkcd). Depending the size of your schema, it might or might not worth it. My guess is unless you have a huge schema and a large number of operations, it's not worth it. |
Wow thanks a lot for taking the time to show me how this can be done. But this is a great thing to have at hand to look at if I happen to find some similar use case. Thanks a lot for putting it all together and sharing it with me! |
Ahah that's fair 👍 . I'll close this one for now. It's still there as reference. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better. |
Description
Would be nice to expose the GraphQL AST to
Plugin
so that users could generate side data without having to parse the schema/operations twiceKotlinLang slack thread: https://slack-chats.kotlinlang.org/t/16651498/i-got-a-type-like-type-flow-id-id-currentstep-flowstep-progr#5519cac4-ca54-4d20-a7c4-16c52cd39871
The text was updated successfully, but these errors were encountered: