Husqvik / GraphQlClientGenerator

GraphQL C# client generator
MIT License
213 stars 49 forks source link

Type 'DisplayableErrorQueryBuilder' already defines a member called 'WithProductVariantsBulkUpdateUserErrorFragment' with the same parameter types #141

Closed daef closed 1 year ago

daef commented 1 year ago

When I generate the client for shopify (their schema can be found here ) the method WithProductVariantsBulkUpdateUserErrorFragment gets generated twice. It works when I remove one of the two identical implementations, but it's irritating to have to manually edit that 120k likes file after each update.

Any ideas how I could avoid this problem?

Husqvik commented 1 year ago

Hi. I assume I would have to create account to access the metadata. Could you store the JSON somewhere and provide link? So I can use it for testing.

daef commented 1 year ago

how can i save the json?

Husqvik commented 1 year ago

It's actually a GraphQL query that the generator queries the API to get the metadata:

query IntrospectionQuery {
    __schema {
      queryType { name }
      mutationType { name }
      subscriptionType { name }
      types {
        ...FullType
      }
      directives {
        name
        description
        locations
        args {
          ...InputValue
        }
      }
    }
  }

  fragment FullType on __Type {
    kind
    name
    description
    fields(includeDeprecated: true) {
      name
      description
      args {
        ...InputValue
      }
      type {
        ...TypeRef
      }
      isDeprecated
      deprecationReason
    }
    inputFields {
      ...InputValue
    }
    interfaces {
      ...TypeRef
    }
    enumValues(includeDeprecated: true) {
      name
      description
      isDeprecated
      deprecationReason
    }
    possibleTypes {
      ...TypeRef
    }
  }

  fragment InputValue on __InputValue {
    name
    description
    type { ...TypeRef }
    defaultValue
  }

  fragment TypeRef on __Type {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
            ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
daef commented 1 year ago

With the query at hand it's easy :) schema.json.txt

Why not add a --export-schema-json to the tool?

Husqvik commented 1 year ago

Pushed new package versions.

Why not add a --export-schema-json to the tool?

The tool is generator primarily. And even though it includes fetching of the metadata I don't think it should be its scope.

daef commented 1 year ago

Yes, but I guess problems with the metadata primarily arise during generation and then the tool choking on the input could replicate its own request. Maybe better call the flag --generate-debug-info to make it clear.