Skip to content

Nested type declarations for complex objects. #181

@RuBAN-GT

Description

@RuBAN-GT

Hi everyone,

First of all thank you for this amazing library! But I found a strange behaviour related to type definition for an object with nested inputs.

Example:
I have a field assets which contains another field metadata that supports input arguments therefore I should define it using zeus autogenerated client:

const response = await client.query()({
  assets: [
    {
      input: {
        where: { ids: ['1234'] },
      },
    },
    {
      assets: {
        id: true,
        metadata: [
          {},
          {
            metadata: {
              field: {
                tagName: true,
                valueType: true,
              },
              '...on TextMetadata': {
                value: true,
              },
            },
          },
        ],
      },
    },
  ],
});

From output I'll have the next structure:

{
  "data": {
    "assets": {
      "assets": [
        {
          "id": "1234",
          "metadata": {
            "metadata": [
              {
                "field": {
                  "tagName": "ID",
                  "valueType": "NUMBER"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

But Typescript type definition for the response is only supporting first-level declaration and an another deep objects with inputs will be defined as query array.

image

I suppose that is a unexpected library behaviour and probably a new bug.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions