ChilliCream / ChilliCream/graphql-platform

Unable to generate clients for schemas generated by `Prisma.io`

Open
#5,274 3 comments 2 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

Is your feature request related to a problem?

I've been working with a schema file generated by Prisma.io but very early on found the issue that said generated uses field equals which causes conflict with the Equals method (error message below)

error CS0102: The type 'StringFilter' already contains a definition for 'Equals'

And the type generated by Prisma.io looks like this:

input StringFilter {
  contains: String
  endsWith: String
  equals: String
  gt: String
  gte: String
  in: [String!]
  lt: String
  lte: String
  not: NestedStringFilter
  notIn: [String!]
  startsWith: String
}

After deep diving into how the generator works, I was able to isolate and mitigate the issue by modifying the method RegisterInputObjectType with this code:

...
rename = inputField.Directives.SingleOrDefault<RenameDirective>();
var fieldName = rename?.Name ?? inputField.Name;
if (string.Equals("equals", fieldName, StringComparison.OrdinalIgnoreCase))
{
    fieldName = "equal";
}

fields.Add(new InputFieldModel(
    GetClassName(fieldName),
...

This solution, although hacky, works but would rather a more robust solution. I don't know if the @rename directive would come in handy with this, but realistic solution, as the team that works with Prisma.io is constantly making changes and at this point, the schema file is over 3k line.

The solution you'd like

Like I stated before, this could be solved with some changes to the RegisterInputObjectType method. What comes to mind is maybe have a way to provide field mappings in the configuration file or optionally, a way to hook a field name mapper into the IDocumentAnalyzerContext interface (as it is passed to the aforementioned method).

I don't know if these are the best approach, but is what first came to mind.

Product

Strawberry Shake

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 the RegisterInputObjectType method and the IDocumentAnalyzerContext interface described in the issue. Trace how input field names become generated C# members, then compare the proposed configuration mapping and field-name hook approaches against the @rename directive. Done means Prisma-generated fields such as equals can produce valid, conflict-free client members without manual schema changes.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.