Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

A Gradle Task to generate introspection JSON from GraphQL Schema SDL format

Notifications You must be signed in to change notification settings

symbaloo/gradle-plugin-graphql-schema-tools

Repository files navigation

GraphQL Schema Tools Gradle Plugin

Various Gradle Tasks to do GraphQL stuff.

SchemaIntrospectionTask

Generates a schema.json file from a schema.graphql file containing GraphQL introspection data.

This is useful when other code generators require the introspection data, but you're using a .graphql schema first approach.

Usage

In your build.gradle.kts:

Add this plugin to your plugins section

plugins {
    id("com.symbaloo.graphql.graphql-introspection").version("1.0.0-SNAPSHOT")
}

Then register a task:

val graphqlSchemaIntrospection by tasks.registering(com.symbaloo.graphql.tools.SchemaIntrospectionTask::class) {
    schemaFile.set(file("src/schema/schema.gql"))
    destination.set(file("build/graphql/main/graphql/schema/schema.json"))
}

OperationOutputTask for Persisted Queries

Generate an OperationOutput.json file at build time from a schema and .graphql query files.

This can be used server-side when only accepting Persisted Queries, but only allowing a certain, at compile time, set of queries.

val operationOutput by tasks.registering(com.symbaloo.graphql.tools.OperationOutputTask::class) {
    val jsonFile = graphqlSchemaIntrospection.get().destination.asFile.get()
    schemaFile.set(jsonFile)
    graphqlFiles.from("src/queries")
    graphqlFiles.include("**/*.graphql")
    destination.set(file("build/graphql/main/graphql/OperationOutput.json"))
    dependsOn(graphqlSchemaIntrospection)
}

About

A Gradle Task to generate introspection JSON from GraphQL Schema SDL format

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages