All Projects → Zaid-Ajaj → Snowflaqe

Zaid-Ajaj / Snowflaqe

Licence: mit
A dotnet CLI tool to work with GraphQL queries: static query verification, type checking and code generating type-safe clients for F# and Fable.

Programming Languages

fsharp
127 projects

Projects that are alternatives of or similar to Snowflaqe

Graphqldesigner.com
A developer web-app tool to rapidly prototype a full stack implementation of GraphQL with React.
Stars: ✭ 587 (+750.72%)
Mutual labels:  graphql, graphql-schema
Graphql Code Generator
A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
Stars: ✭ 7,993 (+11484.06%)
Mutual labels:  graphql, graphql-schema
Graphql
Pure PHP realization of GraphQL protocol
Stars: ✭ 717 (+939.13%)
Mutual labels:  graphql, graphql-schema
Graphql Tools
🔧 Build, mock, and stitch a GraphQL schema using the schema language
Stars: ✭ 4,556 (+6502.9%)
Mutual labels:  graphql, graphql-schema
Graphql Typescript
Define and build GraphQL Schemas using typed classes
Stars: ✭ 67 (-2.9%)
Mutual labels:  graphql, graphql-schema
Get Graphql Schema
Fetch and print the GraphQL schema from a GraphQL HTTP endpoint. (Can be used for Relay Modern.)
Stars: ✭ 443 (+542.03%)
Mutual labels:  graphql, graphql-schema
Graphqlgen
⚙️ Generate type-safe resolvers based upon your GraphQL Schema
Stars: ✭ 796 (+1053.62%)
Mutual labels:  graphql, code-generation
Apollo Tooling
✏️ Tooling for development and production Apollo workflows
Stars: ✭ 2,938 (+4157.97%)
Mutual labels:  graphql, code-generation
Maple
Elixir GraphQL Client | Compile time client code generator for GraphQL APIs based on introspection queries and schema files
Stars: ✭ 20 (-71.01%)
Mutual labels:  graphql, code-generation
Graphql Config
One configuration for all your GraphQL tools (supported by most tools, editors & IDEs)
Stars: ✭ 883 (+1179.71%)
Mutual labels:  graphql, graphql-schema
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+501.45%)
Mutual labels:  graphql, graphql-schema
Sql To Graphql Schema Generator
⚛️ Generate GraphQL Scheme Online From SQL Query - https://sql-to-graphql.now.sh/
Stars: ✭ 32 (-53.62%)
Mutual labels:  graphql, graphql-schema
Graphql Auto Generating Cms
Use your existing graphQL schema to generate CMS in a couple steps. DEMO: http://cms-demo.web4fly.com/
Stars: ✭ 373 (+440.58%)
Mutual labels:  graphql, graphql-schema
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (+663.77%)
Mutual labels:  graphql, graphql-schema
Vim Graphql
A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.
Stars: ✭ 357 (+417.39%)
Mutual labels:  graphql, graphql-schema
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+9847.83%)
Mutual labels:  graphql, graphql-schema
Easygraphql Tester
Test GraphQL queries, mutations and schemas on an easy way! 🚀
Stars: ✭ 242 (+250.72%)
Mutual labels:  graphql, graphql-schema
kobby
Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Stars: ✭ 52 (-24.64%)
Mutual labels:  graphql-schema, code-generation
Strawberry
A new GraphQL library for Python 🍓
Stars: ✭ 891 (+1191.3%)
Mutual labels:  graphql, graphql-schema
Fullstack Graphql
🌈 Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
Stars: ✭ 955 (+1284.06%)
Mutual labels:  graphql, graphql-schema

Snowflaqe Build status Nuget

A dotnet CLI tool for generating type-safe GraphQL clients for F#.

Features

  • Static query analysis, verification and type checking against a remote or local GraphQL schema.
  • Generating idiomatic F# types from GraphQL queries
  • Generating type-safe Fable or F# GraphQL client project in a single command. This project can be then referenced by your application and will be ready to go.
  • Supports GraphQL interfaces and unions
  • Resolves type name collisions when re-using types in a single query
  • Generates a HTTP client with functions that correspond to the query or mutation names. These functions handle exact JSON deserialization for the returned data.

Installation

Install as a global dotnet CLI tool

dotnet tool install snowflaqe -g

Using The Tool

Create a JSON file called snowflaqe.json with the following shape:

{
    "schema": "<schema>",
    "queries": "<queries>",
    "project": "<project>",
    "output": "<output>"
    ["target"]: "<target>",
    ["errorType"]: <custom error type>,
    ["overrideClientName"]: "<clientName>",
    ["copyLocalLockFileAssemblies"]: <true|false>
}

Where

  • <schema> can be one of:
    • A URL to the GraphQL backend
    • A relative path to another JSON file containing the output of the standard Introspection query which you can execute against the backend yourself (this allows for offline verification and type-checking)
    • A relative path to a file with extension .gql or .graphql containing the schema definitions and types
  • <queries> is an absolute or relative path to a directory that contains *.gql files that contain individual GraphQL queries that snowflaqe will run the verification against.
  • <project> is the name of the project will be generated.
  • <output> is an absolute or relative path to a directory where the project will be generated. It is recommended to use an empty directory relative to configuration file because each time you generate and regenarate the project, this directory is cleaned.
  • <errorType> optional custom error type to be generated. See below to learn more.
  • <clientName> optional name for the GraphqlClient class which is {project}GraphqlClient by default when you don't provide this property.
  • <copyLocalLockFileAssemblies> Adds the attribute to the generated F# project for scenarios where embedding the dependencies is required
  • <target> optional the code-generation target which can either be fable (default), fsharp or shared.

Using shared as a code generation target actually builds 3 projects! One contains just the types and can be shared across platforms. The other two reference this shared projects and implement Fable specific client and dotnet specific client, respectively.

After creating the configuration file. You can cd your way to where you have the config file and run:

snowflaqe

which will by default only do static query verification and static type-checking against the <schema>. You can also reference the configuration file in another directory via a relative path:

snowflaqe --config ./src/snowflaqe.json

In this case, the file doesn't necessarily have to be called snowflaqe.json.

Generate Client Project

snowflaqe --generate

snowflaqe --config ./path/to/snowflaqe.json --generate

Will generate a full project in the designated output directory. You can start using the generated project by referencing it from another project using a reference as follows:

<ProjectReference Include=".\path\to\generated\Project.fsproj" />

You can either do this manually or using an IDE such as Visual Studio or Rider that allow you to Right Click -> Add Existing Project.

You don't need to reference extra packages or anything, once you dotnet restore the generated project will pull in the packages that it requires.

It is worth mentioning that the generated project will target netstandard2.0 which means you can use anywhere in .NET Core or even in full .NET Framework v4.7.1+

Screenshots

Here are screenshots of how such generated project looks like. In this case, we have a project generated from the Github GraphQL API (Fable target):

Given the query

GithubSearchQuery

The corresponding query types are generated

GithubSearch

All queries and mutations can be called from a dedicated GraphqlClient

GraphqlClient

Custom Error Type

By default, the error type that is generated in the global types looks like this:

type ErrorType = { message: string }

This type is important because every request you make to the GraphQL backend returns Result<Query, ErrorType list> but the errors that come back are usually determined by the backend and not exposed through the schema. That is why you can customize this error type using the errorType configuration element:

{
    "schema": "<schema>",
    "queries: "<queries>",
    "project": "<project>",
    "output": "<output>",
    "errorType": {
        "CustomErrorType": {
            "Message": "string"
            "Path": "string list"
            "RequestId": "string"
        }
    }
}

which will generate:

type CustomErrorType = {
    Message: string
    Path: string list
    RequestId: string
}

Not Supported

There are a couple of features of the GraphQL specs which snowflaqe doesn't (yet) know how to work with:

  • [ ] Subscriptions
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].