Skip to content

Comments

IntrospectionResultData: fix broken typing#1763

Merged
stubailo merged 1 commit intoapollographql:masterfrom
avindra:patch-1
Jun 6, 2017
Merged

IntrospectionResultData: fix broken typing#1763
stubailo merged 1 commit intoapollographql:masterfrom
avindra:patch-1

Conversation

@avindra
Copy link
Contributor

@avindra avindra commented Jun 5, 2017

The types:

Original : what is currently on master
Fixed: proposal in this PR


data represents a schema that will break due to invalid typing of possibleTypes.

data2 will generate an error.


TL;DR;, I am trying to consume a GraphQL endpoint that is returning [] in possibleTypes, which apollo-client is refusing to accept.

 type Fixed = {
  __schema: {
    types: [{
      kind: string,
      name: string,
      possibleTypes: {
        name: string,
      }[],
    }],
  },
};

type Original = {
  __schema: {
    types: [{
      kind: string,
      name: string,
      possibleTypes: [{
        name: string,
      }],
    }],
  },
};

const data: Fixed = {
    __schema: {
        types: [
            {
                kind: 'someKind',
                name: 'someName',
                possibleTypes: []
            }
        ]
    }
};

const data2: Original = data; 

@apollo-cla
Copy link

@avindra: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@stubailo
Copy link
Contributor

stubailo commented Jun 6, 2017

Whoa. In TypeScript [X] and X[] are actually different?

@avindra
Copy link
Contributor Author

avindra commented Jun 6, 2017

@stubailo yes. You can verify this by pasting the code above in http://www.typescriptlang.org/play

@stubailo
Copy link
Contributor

stubailo commented Jun 6, 2017

Wow, I did not know that. Mind adding a changelog entry for this?

@avindra
Copy link
Contributor Author

avindra commented Jun 6, 2017

@stubailo Updated PR

@stubailo
Copy link
Contributor

stubailo commented Jun 6, 2017

Thanks a lot!

@stubailo stubailo merged commit 956c7ef into apollographql:master Jun 6, 2017
@avindra avindra deleted the patch-1 branch June 6, 2017 20:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 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

Successfully merging this pull request may close these issues.

3 participants