zth/rescript-relay

getConnectionNodes not generated if edges are inside an include directive

mattbeedle opened this issue · 7 comments

I have a fragment that is loaded when a modal is opened. It broke in one of the v1 release candidates.

module AvailableRecipesFragment = %relay(`
  fragment RecipeSelector_fragment on MealPlanSlot
  @refetchable(queryName: "RecipeSelectorAvailableRecipesQuery")
  @argumentDefinitions(
    count: { type: "Int", defaultValue: 48 }
    cursor: { type: "String" }
    filter: { type: "RecipesFilterInput" }
    order: { type: "RecipeOrderInput" }
    includeAvailableRecipes: { type: "Boolean", defaultValue: false }
  ) {
    availableRecipes(
      first: $count
      after: $cursor
      filter: $filter
      order: $order
    )
      @connection(key: "RecipeSelector_availableRecipes")
      @include(if: $includeAvailableRecipes) {
      pageInfo {
        hasPreviousPage
        hasNextPage
        startCursor
        endCursor
      }
      edges {
        node {
          id
          ...

The rescript-relay compilation step still works but I get the following error in the bsb step, even if I cut out any code referencing getConnectionNodes:

 The value getConnectionNodes can't be found in RecipeSelector_fragment_graphql
zth commented

Thanks for the report! Have you confirmed it's indeed the include directive that breaks it...? If you remove it, it works?

@zth yes I did try that, removing the include fixes it :)

zth commented

Interesting, thank you! I'll have a look at this soon.

zth commented

@mattbeedle this is fixed in 0da491a. Will put out a new release soon, just need to see if I can figure out another issue first. Thanks for reporting!

zth commented

@mattbeedle could you try 0.0.0-connection-id-maker-fix-24be613b and verify that works for you? You just add that version to package.json like "rescript-relay": "0.0.0-connection-id-maker-fix-24be613b", and then clean and rebuild your project (including rerunning the Relay compiler).

@zth that's working now. Thanks for this project. It's really great.

zth commented

@mattbeedle thank you! Hoping it'll get better over time too 😄 What are you building with it?