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

Automatic array handling #1

Open
yeegor opened this issue Apr 27, 2021 · 0 comments
Open

Automatic array handling #1

yeegor opened this issue Apr 27, 2021 · 0 comments

Comments

@yeegor
Copy link
Contributor

yeegor commented Apr 27, 2021

Overview

Currently, when an array-like field is getting created, it is necessary to pass an additional argument to the creation process:

const people = new Query('people', true)
    .addField('friends', true)
    .addField(new Field('parents', true)
        .addField('gender')
        .addField('age')
    );

const result = await client.post(people);

result[0].friends[0];
result[0].parents[0].gender;
result[0].parents[0].age;

Expected behavior

In the ideal world, this is handled completely automatically.

Brief mockup:

  1. Use GraphQL type introspection functionality to generate the schema of TS types locally.
  2. When building the type - either during the field generation process or query fetching, use the generated schema to determine whether the field is an array or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant