Skip to content
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

Simplify Giraffe boilerplate? #335

Open
cmeeren opened this issue May 6, 2021 · 5 comments
Open

Simplify Giraffe boilerplate? #335

cmeeren opened this issue May 6, 2021 · 5 comments

Comments

@cmeeren
Copy link

cmeeren commented May 6, 2021

Based on the Star Wars sample, it seems that there is quite a lot of boilerplate that would be needed in any GraphQL API. Only Schema.fs contains the "interesting" domain-specific code and schema; the rest of the files seem to be something that could be entirely automated and would be identical for all services.

Is there a way to avoid the boilerplate?

I just came across Graphscriber, but that seems to only use websockets, and I'm not sure I want that since it could be troublesome for (downtime-free) blue-green deployments.

@jberzy
Copy link
Contributor

jberzy commented May 6, 2021

Hi @cmeeren ,

I've actually been working on that the last few days.

The Program file is pretty reasonable now.

There are a couple things remaining such as WebSocket support, but If you want to give it a go and provide some feedback you can checkout the myget feed below.

https://www.myget.org/feed/fsharp-data-graphql/package/nuget/FSharp.Data.GraphQL.Server.AspNet

Thanks,
Johnn

@cmeeren
Copy link
Author

cmeeren commented May 7, 2021

Excellent, thanks! I'll check it out.

@cmeeren
Copy link
Author

cmeeren commented May 7, 2021

Doesn't work for me. I get this exception from the library.

[08:14:36.104 ERR] Unhandled exception while executing request
System.AggregateException: One or more errors occurred. (The specified type FSharp.Data.GraphQL.Execution+NameValueLookup must derive from the specific value's type Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.Object].)
 ---> System.ArgumentException: The specified type FSharp.Data.GraphQL.Execution+NameValueLookup must derive from the specific value's type Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.Object].
   at void System.Text.Json.ThrowHelper.ThrowArgumentException_DeserializeWrongType(Type type, object value)
   at void System.Text.Json.JsonSerializer.Serialize(Utf8JsonWriter writer, object value, Type inputType, JsonSerializerOptions options)
   at void FSharp.Data.GraphQL.Server.AspNet.Json+GQLResponseConverter.Write(Utf8JsonWriter writer, GQLResponse value, JsonSerializerOptions options)
   at bool System.Text.Json.Serialization.JsonConverter<T>.TryWrite(Utf8JsonWriter writer, in T value, JsonSerializerOptions options, ref WriteStack state)
   at bool System.Text.Json.Serialization.JsonConverter<T>.WriteCore(Utf8JsonWriter writer, in T value, JsonSerializerOptions options, ref WriteStack state)
   at bool System.Text.Json.JsonSerializer.WriteCore<TValue>(JsonConverter jsonConverter, Utf8JsonWriter writer, in TValue value, JsonSerializerOptions options, ref WriteStack state)
   at async Task System.Text.Json.JsonSerializer.WriteAsyncCore<TValue>(Stream utf8Json, TValue value, Type inputType, JsonSerializerOptions options, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at async Task Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Step<Unit> [email protected](Unit unitVar0)
   at Step<a> FSharp.Control.Tasks.TaskBuilder.tryWith<a>(FSharpFunc<Unit, Step<a>> step, FSharpFunc<Exception, Step<a>> catch)

@jberzy
Copy link
Contributor

jberzy commented May 7, 2021

@cmeeren,

Do you have more info on how I can repro that?

Thanks,
John

@cmeeren
Copy link
Author

cmeeren commented May 8, 2021

Unfortunately not; this was when experimenting with an existing project with proprietary code. I can't prioritize making a minimal repro right now. Currently testing out various GraphQL frameworks. If I get back to FSharp.Data.GraphQL, I'll revisit this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants