fullstack-tutorial icon indicating copy to clipboard operation
fullstack-tutorial copied to clipboard

Using fragment in `launches.js` stops data from being loaded.

Open wojciech-bilicki-oke opened this issue 6 years ago • 2 comments

Are you sure that presented fragment is correct? I mean it looks right but when changing from

const GET_LAUNCHES = gql`
  query launchList($after: String) {
    launches(after: $after) {
      cursor
      hasMore
      launches {
        id
        isBooked
        rocket {
          id
          name
        }
        mission {
          name
          missionPatch
        }
      }
    }
  }
`;

to solution with fragments:

export const LAUNCH_TILE_DATA = gql`
  fragment LaunchTile on Launch {
    __typename
    id
    isBooked
    rocket {
      id
      name
    }
    mission {
      name
      missionPatch
    }
  }
`;

const GET_LAUNCHES = gql`
  query GetLaunchList($after: String) {
    launches(after: $after) {
      cursor
      hasMore
      launches {
        ...LaunchTile
      }
    }
  }
  ${LAUNCH_TILE_DATA}
`;

Data is never properly loaded into the component: screenshot 2018-11-20 at 10 16 16

When using the fragments I can't see any POST request performed against my graphql server.

wojciech-bilicki-oke avatar Nov 20 '18 09:11 wojciech-bilicki-oke

Yeah, this seems like some weird bug. I can't find the problem. When I run the final/client with fragments and it works on the same localhost server but from what I've edited in start/client it fails to load the data. It sometimes works if you set fetchPolicy to "no-cache".

muedie avatar Dec 17 '18 09:12 muedie

The code in section 6 of the tutorial is broken. I'm personally reworking it in the next couple of days to fix it.

Scott

smolinari avatar Dec 17 '18 12:12 smolinari