Skip to content

Conversation

@KATT
Copy link

@KATT KATT commented Jun 10, 2019

You don't have to merge this or anything. I saw your Medium post, I just thought I'd show that you can do dynamically typechecked fragments based on your GraphQL-queries.

This way, the typecheck will fail if you try to use a property we omitted in the actual fragment in the GraphQL-query.

Just not sure if you're aware or not :)

query LaunchList {
query LaunchListQuery {
launches {
flight_number
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run yarn start then try to remove this line with flight_number for instance and TypeScript starts complaining

Failed to compile.

/Users/alex/dev/graphql-react-typescript-spacex/src/components/LaunchList/LaunchList.tsx
TypeScript error: Property 'flight_number' does not exist on type 'LaunchListQuery_launches'.  TS2339

    24 |                 key={i}
    25 |                 className={`${className}__item`}
  > 26 |                 onClick={() => handleIdChange(launch.flight_number!)}
       |                                                      ^
    27 |               >
    28 |                 {launch.mission_name} ({launch.launch_year})
    29 |               </li>

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

Successfully merging this pull request may close these issues.

1 participant