graphql-to-elm icon indicating copy to clipboard operation
graphql-to-elm copied to clipboard

Multiple fragments generate mutually exclusive records

Open Yagger opened this issue 2 years ago • 2 comments

Given schema

type Query {
  books: [Book]
}

type Book {
  title: String
  author: String
}

query

query {
  books {
    ...foo
    ...bar
  }
}

fragment foo on Book {
  title
}

fragment bar on Book {
  author
}

generates a type that is either Book (title) OR Book2 (author)

type alias Query =
    { books : Maybe.Maybe (List (Maybe.Maybe Book3))
    }

type Book3
    = OnBook Book
    | OnBook2 Book2

type alias Book =
    { title : Maybe.Maybe String
    }

type alias Book2 =
    { author : Maybe.Maybe String
    }

while expected is a plain record with both title AND author

type alias Query =
    { books : Maybe.Maybe (List (Maybe.Maybe Book))
    }

type alias Book =
    { title : Maybe.Maybe String
    , author : Maybe.Maybe String
    }

Yagger avatar Jan 18 '23 19:01 Yagger

Thank you for the report. Indeed that is not correct. I'll see if I can find some time to look into it.

harmboschloo avatar Jan 19 '23 19:01 harmboschloo

I just publish v1.0.4 which should fix this issue. Please let me know if you experience any more problems.

harmboschloo avatar Jan 20 '23 15:01 harmboschloo