Khan / Khan/genqlient

Plugins support

Open
#390 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
1.3k
Forks
144
Avg merge
4h 50m
Merged PRs (30d)
1

Description

Is your feature request related to a problem? Please describe.
Currently, field descriptions from the GraphQL schema are discarded during code generation, and there is no way to retain or access them. Schema generation tools that use field tags to provide additional context can benefit from keeping the descriptions

Describe the solution you'd like
Introduce a new plugins section in the genqlient.yaml configuration file. This section would allow users to define custom plugins for field tags. Each plugin would specify:

  • A name for the tag.
  • A path to a shared object file implementing the plugin.

The plugin function should have the following signature (not final):

type PluginInput struct {
	GraphQLName string
	Description string
}

// The function can 
// - return error if something goes wrong. this will stop generation
// - return not Nil result in success case
// - return Nil as a result if the tag should be skipped for provided input
func FieldTagPlugin(input generate.PluginInput) (*string, error) {
  // Implementation.
}

Configuration example:

plugins:
  field_tags: #called field_tags to leave place for other potential plugins
    - name: jsonschema
      path: plugins/jsonschema.so

Describe alternatives you've considered

Additional context
More details about my case.

I have a model generated by the genqclient tool. And I need of schema for it. For this another tool is used, but without descriptions some context is missed. Tool that generates schemas can add descriptions if they store in a particular tag. So i'm trying to connect two tools together.

I already have created and tested a draft PR with the solution: https://github.com/Khan/genqlient/pull/389

Still need to take care of tests. But some initial review/feedback would be helpful

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing draft PR #389 and the genqlient.yaml configuration, then trace the genqclient generation path where GraphQL field descriptions are discarded. Done means the plugin configuration and proposed FieldTagPlugin behavior are settled, field descriptions can be retained through generation, and tests cover successful, skipped, and failing plugins.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.