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

Better Fragment Handling #164

Open
Tracked by #163
brettjurgens opened this issue Mar 22, 2018 · 1 comment
Open
Tracked by #163

Better Fragment Handling #164

brettjurgens opened this issue Mar 22, 2018 · 1 comment

Comments

@brettjurgens
Copy link
Contributor

from this comment by @BinaryMuse #76 (comment):

export interface MyTestQuery {
  resource:
    | SelectionOnResource &
        Partial<IFragmentIssue> &
        Partial<IFragmentOrganization>
    | null;
}

export interface IFragmentIssue {
  __typename: string;
  id: string;
  title: string;
  author: SelectionOnAuthor | null;
}

export interface IFragmentOrganization {
  __typename: string;
  orgName: string | null;
}

but since we know statically what all the typenames are, it could be something like

export interface MyTestQuery {
  resource:
    | IFragmentIssue
    | IFragmentOrganization
    | DefaultSelectionOnResource
}

export interface IFragmentIssue {
  __typename: "Issue";
  id: string;
  title: string;
  author: SelectionOnAuthor | null;
}

export interface IFragmentOrganization {
  __typename: "Organization";
  orgName: string | null;
}

export interface DefaultSelectionOnResource {
  __typename: string;
}
@brettjurgens
Copy link
Contributor Author

Completely off the top of my head and this might be inaccurate, but my thoughts are:

  • need to get specific __typename (already going to do)
  • in order to do an OR, we probably need to:
    • flatten fragments without a ... on Type
    • ensure that all cases are covered (might not be necessary if OR'd with non-fragment selection)
    • either:
      • extend fragments with the default selection, without the __typename
      • OR the fragments and AND with the selection on root type (minus __typename)

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