-
-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F# Support #3670
F# Support #3670
Conversation
Is it possible to represent non-nullable GraphQL type by F# record? now I can do nullable type by this method: [<ReferenceEquality>]
type Author = { Name: string }
[<ReferenceEquality>]
type Book = { Title: string; Author: Author }
type Query() =
member this.Book() =
{ Title = "F#"
Author = { Name = "Jon" } }
type Mutation() =
member this.CreateBook() =
{ Title = "F#"
Author = { Name = "Jon" } }
|
Never mind, I found this |
Kudos, SonarCloud Quality Gate passed! |
Hi @michaelstaib F# support with HotChocolate would be awesome! I will be looking forward to testing it out with Snowflaqe 🙏 |
Hello @michaelstaib. Are we expecting this in Sept. milestone? What would it include in terms of F# support? |
This is a bit cumbersome in F#: type Query() =
member this.Book() =
{ Title = "F#"
Author = { Name = "Jon" } }
type Mutation() =
member this.CreateBook() =
{ Title = "F#"
Author = { Name = "Jon" } } There is no partial classes, it gets awkward. Secondly these classes feel redundant, especially in F#. Mutation functions usually are not dependent on each other by state, so they shouldn't share class anyway. I'd prefer in F# if we could define mutations and queries like functions. If it's possible, by allowing somehow to annotate functions with "Mutation": [<Mutation>]
let createBook book (appDbContext: AppDbContext) =
appDbContext.Books.Add(book) |> ignore
appDbContext.SaveChanges()
// ...
[<Query>]
[<UsePaging>]
[<UseProjection>]
[<UseFiltering>]
[<UseSorting>]
let getBooks ([<Service>] dbContext: AppDbContext) =
dbContext.Books |
@Ciantic are there global functions in F# or are they always members of a class or struct? |
OK, looked at it ... seems to work ... I can probably put something into one of the next builds ... I think with this kind of function it can also become quite nice to create schema first and define resolvers... have to play a bit with it |
It's notable that in F# the functions are usually defined in curried form, which also requires support in the HotChocolate to work well. Like https://github.com/Ciantic/TestGraphQLWithFsharp/blob/master/Program.fs |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm sure there's plenty of people who wouldn't want this closed? |
I am interested on this too. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@michaelstaib Please mark this as not stale |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
was this PR forgotten? |
I am closing this PR as we have a newer one #5595. |
This PR represents the initial work to determine what we need to make this a great API for F#.
In this initial PR we will re-create the StarWars example with F# and write some F# unit tests to see where the pain points are.
Todo:
https://github.com/adelarsq/hotchocolate_fsharp_sample