fsprojects / FSharp.Data.GraphQL

FSharp implementation of Facebook GraphQL query language.
http://fsprojects.github.io/FSharp.Data.GraphQL/
MIT License
395 stars 72 forks source link

oneOf input types #442

Open laurencepettitt opened 9 months ago

laurencepettitt commented 9 months ago

Description

The RFC for oneOf input types is nearing completion and is in the phase of gathering feedback from libraries and users

graphql-js and HotChocolate already have implemented this feature based on the RFC.

Repro steps

N/A

Expected behavior

I imagine that an F# discriminated union, like this

type Cat = { Name: string; Meows: bool }
type Dog = { Name: string; Barks: bool }
type Pet = 
    | DogPet of Dog
    | CatPet of Cat

could be mapped to a GraphQL oneOf input type, like this

input Cat {
    name: String
    meows: Boolean
}
input Dog {
    name: String
    barks: Boolean
}
input Pet @oneOf {
    dogPet: Dog
    catPet: Cat
}

Actual behavior

oneOf input type not supported.

Known workarounds

Essentially none.

Related information

N/A

xperiandri commented 9 months ago

Yep, this is doable. Would you like to help? I suppose we need #380 to be merged and on top of it we can add oneOf