Questions tagged [graphql-go]

github.com/graphql-go/graphql is a Go package that provides an implementation of GraphQL. Use this tag together with [go] and other tags about the web frameworks, if any, that you use graphql-go with.

The graphql-go repository is located at: https://github.com/graphql-go/graphql

34 questions
3
votes
1 answer

Graphql : Schema is not configured for mutations in Go

I am trying to write Graphql Mutation inside Go. I am using github.com/graphql-go/graphql library. Here is the code i have written for the same. package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" …
rachana
  • 3,344
  • 7
  • 30
  • 49
2
votes
0 answers

graphql-go ResolveParams cannot be casted to actual type

Graphql endpoint gets an array of ints, resource_ids. This is the whole resolve function: "resourceFilterByIds": &graphql.Field{ Type: graphql.NewList(resourceType), Description: "List resources matching IDs.", …
Brotkrumen
  • 59
  • 3
2
votes
0 answers

Generating a GraphQL schema from a JSON schema in GoLang

I am new to Go and GraphQL and was wondering if it is possible to programmatically build the schema from a JSON schema fetched from an endpoint. I am currently looking to use gqlgen which allows for manually defining your schema via SDL (Schema…
2
votes
0 answers

How to use middleware [Directives] in GraphQL resolvers?

I've been using github.com/graphql-go/graphql library for my GraphQL project. Currently, I'm trying to add authorization middleware to the following query. Using github.com/99designs/gqlgen library we can achieve this by adding Directives. But…
Masudur Rahman
  • 1,585
  • 8
  • 16
2
votes
0 answers

graphql issue with route in golang

I used router in my code as: router := chi.NewRouter() router.Use(auth.Middleware()) srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) router.Handle("/", playground.Handler("GraphQL…
2
votes
1 answer

Get the query name from the request in "github.com/graphql-go/graphql"

I'm creating a graphql api in golang using "github.com/gin-gonic/gin" "github.com/graphql-go/graphql" To secure my api i will use a jwt token and i want to keep my api to be fully graphql (the only route allowed is localhost:9000/graphql) Is there…
2
votes
1 answer

How to make a request using graphql-go

I need to make a request to an external API which uses GraphQL using Go. To do so, I'm using the following client: https://github.com/graphql-go/graphql but the documentation is very limited and don't quite understand how to perform the request. My…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
2
votes
1 answer

Subobject is not parsed graphql with golang

The object itself inside the object is parsed with an empty field. input: { Products(search: {limit: 1, filters: {product_id: {gte: 5}}}) { data { product_id product_name sales_history{ total_check } } …
1
vote
0 answers

Weird Error Implementing GraphQL Go Resolvers

Here is my resolver: // CreateBook is the resolver for the createBook field. func (r *mutationResolver) CreateBook(ctx context.Context, input model.NewBook) (*model.Book, error) { book := &model.Book{ ID: input.ID, …
Bedrock
  • 11
  • 1
1
vote
1 answer

How to prevent users from requesting all results in graphlql-go

type Book struct { ID string `json:"id"` } bookType := graphql.NewObject(graphql.ObjectConfig{ Name: "Books", Description: "Books List", Fields: graphql.Fields{ "id": &graphql.Field{ …
Nicole Staline
  • 557
  • 4
  • 15
1
vote
1 answer

How to setup dataloaders for GraphQL in graphql-go?

I am using a gqlgen package for Golang and I am trying to implement a Dataloaders. This is the Dataloader I am using: https://github.com/graph-gophers/dataloader I did everything as in the Tutorial, but I am not able to load all keys as slices of…
1
vote
1 answer

How to use go-vcr with githubv4 ? - getting httpClient Transport

Looking at the set up for go-vcr // Start our recorder r, err := recorder.New("fixtures/etcd") if err != nil { log.Fatal(err) } defer r.Stop() // Make sure recorder is stopped once done with it // Create an etcd…
mcbain83
  • 492
  • 6
  • 19
1
vote
1 answer

Golang GraphQL always returns one variable as null

GraphQL query field post and list return all data except created_at. It always null. I check GetPostBySlug and GetPostList variables and it contain data from Postgres. Where is my mistake? model.go package post type Post struct { Slug …
oyaro-tech
  • 13
  • 5
1
vote
0 answers

graphql-go a union of scalars return type

i'm trying to make a filed that's either going to be a string or a date or an int var PredSearchElementType = graphql.NewObject(graphql.ObjectConfig{ Name: "PredSearchElementType", Fields: graphql.Fields{ "_id": &graphql.Field{ …
1
vote
0 answers

How to pass the result(response) of a GraphQL query to a mutation as an argument(input)?

I'm building a cli application using GitHub API V4. I need to remove all labels a repository has. URL: https://api.github.com/graphql HEADERS: Accept: application/vnd.github.bane-preview+json Authorization: bearer I need to get the…
1
2 3