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

A way for plugins to manage library definitions #697

Open
BoD opened this issue Dec 6, 2023 · 2 comments
Open

A way for plugins to manage library definitions #697

BoD opened this issue Dec 6, 2023 · 2 comments

Comments

@BoD
Copy link
Contributor

BoD commented Dec 6, 2023

We are the maintainers of the Apollo Kotlin plugin, which depends on the GraphQL one.

The GraphQL plugin already supports Apollo Kotlin specific definitions from this file and through the GraphQLLibraryManager.

When we've added new definitions in our library in the past we've opened PRs in this repo to update that file.

But a more dynamic mechanism (in GraphQLLibraryManager or a dedicated EP I suppose?) where our plugin could add/remove definitions on the fly would be great. We would be more autonomous and reactive when new definitions are added to our lib, and this would also enable the ability to have different versions of the definitions, depending on which version is used by the project, or which features are enabled in the lib's configuration.

There is probably some overlap with #624, which is as I understand it essentially the same ask, but from an end-user point of view.

@vepanimas
Copy link
Collaborator

Hi @BoD! How will you provide a schema file in your plugin? Will you follow the same approach as the GraphQL plugin?

@BoD
Copy link
Contributor Author

BoD commented Dec 7, 2023

This is to be determined - but I think the most flexible way would probably to have an API that takes a String as an input, so a plugin could programmatically build this String to handle different cases.

To give your more context, in Apollo Kotlin (and other Apollo tools) we have a generic @link mechanism where a schema can declare to import certain definitions. You can read more about it here. We intend to leverage this mechanism in the future any time we need to add new definitions.

So for instance, in v4 we are adding a new directive @catch, and for users to use it, they'll have to import it this way:

extend schema @link(
  url: "https://specs.apollo.dev/nullability/v0.1", 
  import: ["@catch", "CatchTo"]
)

When doing this Apollo Kotlin will add the @catch directive to the user's schema so it can be used in queries.

The ultimate goal for us would be to have support for this mechanism in the plugin. So when @catch is imported via @link, then it should be recognized in the editor.

I hope this makes sense :)

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

2 participants