Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Handle NonNull/List Types Properly #56

Merged
merged 3 commits into from
Sep 27, 2024
Merged

Conversation

bradschwartz
Copy link
Contributor

Fixes where NonNull and ListTypes were defaulting to scalar types, because we were returning field_type for their kind, which is just that objects name.

Looking at the schema.json fixture for Droid (updated test):

{
  "args": [
    {
      "defaultValue": null,
      "description": null,
      "name": "episode",
      "type": {
        "kind": "NON_NULL",
        "name": null,
        "ofType": {
          "kind": "SCALAR",
          "name": "String",
          "ofType": null
        }
      }
    }
  ],
  "deprecationReason": null,
  "description": "Get droids for episode",
  "isDeprecated": false,
  "name": "droidsInEpisode",
  "type": {
    "kind": "LIST",
    "name": null,
    "ofType": {
      "kind": "OBJECT",
      "name": "Droid",
      "ofType": null
    }
  }
}

Previously, the field_kind function would return Droid. Now, it will properly return OBJECT and links will render properly.

Fixes where NonNull and ListTypes were defaulting to scalar types, because we were returning field_type for their kind, which is just that objects name.

Looking at the `schema.json` fixture for Droid (updated test):

```json
{
	"args": [
                {
                  "defaultValue": null,
                  "description": null,
                  "name": "episode",
                  "type": {
                    "kind": "NON_NULL",
                    "name": null,
                    "ofType": {
                      "kind": "SCALAR",
                      "name": "String",
                      "ofType": null
                    }
                  }
                }
              ],
              "deprecationReason": null,
              "description": "Get droids for episode",
              "isDeprecated": false,
              "name": "droidsInEpisode",
              "type": {
                "kind": "LIST",
                "name": null,
                "ofType": {
                  "kind": "OBJECT",
                  "name": "Droid",
                  "ofType": null
                }
              }
            }
```

Previously, the `field_kind` function would return `Droid`. Now, it will properly return `OBJECT` and links will render properly.
@bradschwartz bradschwartz requested a review from a team as a code owner September 27, 2024 16:17
@bradschwartz bradschwartz changed the title bugfix: Recurse on FieldKind for NonNull/List Types bugfix: Handle NonNull/List Types Properly Sep 27, 2024
@bradschwartz bradschwartz merged commit 0db6f88 into master Sep 27, 2024
12 checks passed
@bradschwartz bradschwartz deleted the bugfix/field_kind branch September 27, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants