bromanko / capemay

1 stars 0 forks source link

Add Fly.io GraphQl Client #1

Closed bromanko closed 1 year ago

bromanko commented 1 year ago

This client will be used by the admin server to create new tenants.

bromanko commented 1 year ago

Started using FSharp.Data.GraphQL but it looks to be a dead end. I want to put the client in the CapeMay.Admin.Domain library. However the introspection schema must reside alongside the code that consumes it per this issue. So this is out.

Came across Snowflaq which statically generates the client. I'll try this next.

bromanko commented 1 year ago

Snowflaq configuration

The config file can be placed in a directory. So let's make src/flyio-graphql-client and put it there. The schemas and queries are also inputs so they will go in there as src/flyio-graphql-client/snowflaqe.json and src/flyio-graphql-client/queries.

Snowflaq will generate a new project. Let's call the project FlyIo.

Set asyncReturnType to task since F# is moving this way.

Resulting config:

{
    "schema": "src/flyio-graphql-client/fly_schema.json",
    "queries": "queries",
    "project": "FlyIo",
    "output": "src/FlyIo",
    "target": "fsharp",
    "asyncReturnType": "task",
    "serializer": "newtonsoft"
}

Just

Add a just command to run snowflaqe:

dotnet snowflaqe --config src/flyio-graphql-client/snowflaqe.json --generate
bromanko commented 1 year ago

I need to look in to customizing the errorType. This is a reminder.