Skip to content

labd/apollostudio-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apollo Studio Go SDK

Go SDK for Apollo Studio.

Installation

go get github.com/labd/apollostudio-go-sdk

Usage

package main

import (
	"context"
	"github.com/labd/apollostudio-go-sdk/apollostudio"
)

func main() {
	key := "your-api-key"
	ref := "your-schema-reference"

	client, err := apollostudio.NewClient(key, ref)
	if err != nil {
		panic(err)
	}

	_, _ := client.SubmitSubGraph(
		context.Background(),
		&apollostudio.SubmitOptions{
			SubGraphSchema: []byte("schema { query: Query } type Query { hello: String }"),
			SubGraphName:   "my-subgraph",
			SubGraphURL:    "https://my-subgraph.com/graphql",
		},
	)
}

The client allows for several additional options to be set, which can extend its functionality.

var clientOpts = []apollostudio.ClientOpt{
    apollostudio.WithHttpClient(http.DefaultClient),
    apollostudio.WithDebug(true),
    apollostudio.WithUrl("https://studio.apollographql.com/api/graphql"),                       
}

client, err := apollostudio.NewClient(key, ref, clientOpts...)

Contributing

Apollo Studio GraphQL explorer can be found here.