Skip to content

Star-wars-api sample code is wrong #470

Closed
@pkese

Description

@pkese

I'm looking at star-wars-api/Schema

Note that the Human.HomePlanet, as defined in data in the last line contains Planet.Name rather than Planet.Id.

type Human =
    { Id : string
      Name : string option
      Friends : string list
      AppearsIn : Episode list
      HomePlanet : string option }

type Planet =
    { Id : string
      Name : string option
      mutable IsMoon : bool option }

let planets =
    [ { Id = "1"
        Name = Some "Tatooine"
        IsMoon = Some false} ]

let humans =
    [ { Id = "1000"
        Name = Some "Luke Skywalker"
        Friends = [ "1002"; "1003"; "2000"; "2001" ]
        AppearsIn = [ Episode.NewHope; Episode.Empire; Episode.Jedi ]
        HomePlanet = Some "Tatooine" }   // <-- here

I guess the idea here was that a Human's HomePlanet was supposed to contain Planet.Id, e.g "1" for Tatooine rather than planet's name (Some "Tatooine") as defined in the list of humans.

This omission is really unpleasant. I started reading this sample code because I wanted to figure out how foreign-key relationships are supposed to be modeled with this library and this kind of leaves it unexplained.

In my real world case, where I would like to use FSharp.Data.GraphQL, I'd like to do joins across database tables and based on the documentation here I don't really know how to model that and where to start from.

Do I need to include FSharp.Data.GraphQL.Server.Relay to achieve that (there are some Edge and Connection defined there - is that for relationships)? Why is this Relay in a separate namespace, i.e. not part of the main library?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions