Skip to content

Scala library to convert one or more API Builder Service into a valid GraphQL Schema

License

Notifications You must be signed in to change notification settings

apicollective/apibuilder-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apibuilder-graphql

GraphQL Code Generator for ApiBuilder Services.

Install

      "io.apibuilder" %% "apibuilder-graphql" % "0.0.2"

Usage

    import cats.data.Validated.{Invalid, Valid}
    import io.apibuilder.validation.MultiService
    import io.apibuilder.graphql.GraphQLCodeGenerator

    MultiService.fromUrls(
      List(
        "https://app.apibuilder.io/apicollective/apibuilder-common/latest/service.json",
        "https://app.apibuilder.io/apicollective/apibuilder-spec/latest/service.json",
        "https://app.apibuilder.io/apicollective/apibuilder-generator/latest/service.json",
        "https://app.apibuilder.io/apicollective/apibuilder-api/latest/service.json"
      )
    ) match {
      case Left(errors) => {
        println(s"Error downloading service: " + errors.mkString(", "))
      }
      case Right(multiService) => {
        GraphQLCodeGenerator.Default.generate(multiService) match {
          case Valid(schema) => {
            println("Schema is valid.")
            schema.files.foreach { f =>
              println(s"File: " + f.name)
              println(f.contents)
              println("")
            }
          }
          case Invalid(errors) => {
            println("Schema did not validate:")
            errors.toNonEmptyList.toList.foreach { error =>
              println(s" - ${error}")
            }
          }
        }
      }
    }

About

Scala library to convert one or more API Builder Service into a valid GraphQL Schema

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •