[SOLVED] Bad field name in GraphQL schema description

Hi I found one mistake in GraphQL schema. When I have Array localizable field and this field has Label with spaces, then GraphQL schema generator CachingGraphQLService create next:

generated schema for this field is:

        {
          "kind": "OBJECT",
          "name": "FooterTest poleChildDto",
          "description": "The structure of the Patička.Test pole nested schema.",
          "fields": [
            {
              "name": "content",
              "description": "The Test pole/Příloha nested field.",
              "args": [],
              "type": {
                "kind": "LIST",
                "name": null,
                "ofType": {
                  "kind": "NON_NULL",
                  "name": null,
                  "ofType": {
                    "kind": "OBJECT",
                    "name": "AssetDto",
                    "ofType": null
                  }
                }
              },
              "isDeprecated": false,
              "deprecationReason": null
            },

This is not parsable format for any 3th part aplication (etc.: Gatsby.js). Bug is, that field name is created by Label. In String field type is Field created by name.

I prepared fix in this commit https://github.com/xixaoly/squidex/commit/40b75a02a1355d923b94bcdeec8c094d8832f1ae

Is it Ok?

Regards
Adam

The makes sense (almost)

Recently I created this extension methods to give me all fields names:

The problem was that field names are converted to pascalCase automatically, which could create duplicates.

E.g. you have two fields:

  • my-field => myField
  • my_field => myField

The extension methods adds a suffix to the second one

  • my-field => myField2
  • my_field => myField2

It would make sense to use this name instead. I think you have to it as a a parameter to GetGraphType here:

And then pass it over to the nested type.

It is a very special case, but at least it would be covered.

Thanks, unique name is good hint. I fixed code in this commit https://github.com/xixaoly/squidex/commit/7a3ca864b92c5488a4137daf08cc1a4c9309ae8a. But I am not sure, that QueryGraphTypeVisitor is the best place for field name store. But I havnn’t better idea.

Regards
Adam

Yes, I had the same idea. Probably not a nice solution, but if it works … :wink:

Can you create a PR?

Pull request is done