Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jesse-apollo/gofed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apollo Federation for graphql-go

This is a WIP implementation of Federation using graphql-go.

Basic usage

go get github.com/jesse-apollo/gofed

Create your graphql-go fields map:

// declare userType above here
var queryFields = graphql.Fields{
	"user": &graphql.Field{
		Type: userType,
		Args: graphql.FieldConfigArgument{
			"id": &graphql.ArgumentConfig{
				Type: graphql.String,
			},
		},
		Resolve: func(p graphql.ResolveParams) (interface{}, error) {
			// ...
			return nil, nil
		},
	},
}

Then generate the schema with:

fed := gofed.NewFederation()
schema := fed.BuildSubgraphSchema(queryFields, nil)

http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
    result := executeQuery(r.URL.Query().Get("query"), schema)
    json.NewEncoder(w).Encode(result)
})

About

Federation for graphql-go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages