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

Field in type IntrospectionResultData defined incorrectly #2959

Closed
dotansimha opened this issue Feb 5, 2018 · 0 comments
Closed

Field in type IntrospectionResultData defined incorrectly #2959

dotansimha opened this issue Feb 5, 2018 · 0 comments

Comments

@dotansimha
Copy link
Contributor

dotansimha commented Feb 5, 2018

in TypeScript >=2.7 (since this PR), the definition of type[] and [type] are different.
[type] also enforces a length of 1 for the array, while type[] just enforces the Array type without length.

Related to this PR: (fixed the inner array)
#1763

Actual outcome:
Field types in IntrospectionResultData defined as:

export type IntrospectionResultData = {
  __schema: {
    types: [{
      kind: string;
      name: string;
      possibleTypes: {
        name: string;
      }[];
    }];
  };
};

Intended outcome:

It should be:

export type IntrospectionResultData = {
  __schema: {
    types: {
      kind: string;
      name: string;
      possibleTypes: {
        name: string;
      }[];
    }[];
  };
};

How to reproduce the issue:
Use typescript@2.7.1 and define IntrospectionResultData with more than one type, for example:

const cache = new InMemoryCache({
  fragmentMatcher: new IntrospectionFragmentMatcher({
    introspectionQueryResultData: {
      __schema: {
        types: [{
            kind: 'UNION',
            name: 'A',
            possibleTypes: [
              { name: 'AA' },
              { name: 'AB' },
            ]
          }, {
            kind: 'UNION',
            name: 'B',
            possibleTypes: [
              { name: 'BA' },
              { name: 'BB' }
            ]
          },
        ]
      },
    }
  }),
});

As a temporary workaround, it's possible to add as any to the types array value.

Version

  • apollo-client@2.2.2
  • apollo-cache-inmemory@1.17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant