ChilliCream / ChilliCream/graphql-platform

Group Queries By Type

Open
#8,991 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ strawberry shake
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Product

Strawberry Shake

Is your feature request related to a problem?

I don't know if this is possible as I haven't found any documentation related to this. But I would like to be able to group graphql queries by a subtype when generating a client.

For example, I have a server that expose a graphql endpoint, as part of my Queries available on said server I have a ListUsers and a ListRoles query.

Now I have a client project, in which I do all the Strawberry shake tooling shenanigans to fetch the sdl, and generate a client. And lets also assume I have created two *.graphql files. i.e. Users.graphql and Roles.graphql each with their respective query definitions.

The client that is generated, lets call it MyApiClient, will directly have two functions ListUsers and ListRoles, as defined in the *.graphql files I mentioned above. Now in a small situation this is fine, however, as the number of queries increase this clients starts becoming quiet bloated, and it would be nice to have those functions under a sub property on the the client. e.g. instead of calling MyApiClient.ListUsers it would be MyApiClient.Users.ListUsesrs

The solution you'd like

Would it be possible to have the source code generator pick up the name of the file (semantics around naming convention aside) and use that as a sub-property on the client.
So using my example above, all my queries defined in my Users.graphql file would be referenced under MyApiClient.Users.<xyz> and so on.

The way I have semi-achieved this at the moment is at the client level. Where in my project, I have defined mulitple graphql templates all from the same source, and just define limit the query files that it uses.
So at the moment my project has MyUsersApiClient and MyRolesApiClient. Which I don't hate, other than the fact that I have to ensure multiple sdls are kept up-to-date.

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 with Strawberry Shake's source code generator and the *.graphql inputs, especially how Users.graphql and Roles.graphql become members of MyApiClient. Define the grouping and naming behavior, then verify that queries from each file are exposed under the corresponding client sub-property without requiring multiple clients.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.