33 questions
1
vote
1
answer
172
views
Graphql-go Has No Built-In Validation For Argument/Variables Passed On?
I am building golang graphql endpoint with graphql-go
https://github.com/graphql-go/graphql
Here is chunk of my resolver.go
func GetRootMutation(db *gorm.DB, req *http.Request) *graphql.Object {
...
2
votes
0
answers
29
views
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),
...
2
votes
0
answers
325
views
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 ...
2
votes
0
answers
253
views
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 ...
1
vote
0
answers
62
views
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....
0
votes
1
answer
1k
views
How to attach JWT token to the header of graphql subscription
I am currently building chat application with microservice architecture, where auth(login and signup) service and chat service are separated using Graphql. I was trying to attach a JWT to the request ...
1
vote
1
answer
684
views
Pass parent resolver arguments in child resolver
I have a nested GraphQL query with the following structure
query{
parentMetrics(cityNames: ["Cali"], orderingDateFrom: "2021-01-01"){
sales
...
1
vote
1
answer
83
views
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",
...
2
votes
0
answers
204
views
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{}}))
...
3
votes
1
answer
2k
views
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, ...
1
vote
1
answer
395
views
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 ...
1
vote
1
answer
946
views
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
...
0
votes
2
answers
551
views
$push string as an array in mongo document
I'm having trouble understanding arrays in Go, especially with both graphql and mongo. With JS this all would've been a breeze for me, but I'm wondering if you can look at what I have and point out ...
0
votes
1
answer
308
views
GraphQL - Use Object as argument
I am building an API using GraphQL and one of the options of the API is to place an order
I am using Go 1.16 with graphql-go as the GraphQL backend
The JSON format for the PlaceOrder API call is:
{
...
0
votes
1
answer
566
views
Some of my go-graphql queries' fields are returning null while other fields come back fine and other similar queries work all together
I have been experimenting with go-grapqhql and I have been able to successfully create some schemas such as this:
type Artist struct {
ID string `json:"id,omitempty"`
Name string `...
0
votes
1
answer
483
views
Why doesn't my GraphQL query return the right result when triggered from GO?
I'm new to both Hasura/Graphql and GO. I've succeeded in writing a couple of Hasura actions which are supported by a GO server which in turn calls the Hasura server to run a query. These both work. ...
3
votes
1
answer
2k
views
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"
"...
1
vote
0
answers
155
views
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",
...
-2
votes
1
answer
473
views
Run multiple queries(SELECT * from emp; Select * from adm;) for postgres and get result in a two different struct IN GO(GOLANG)
I am using Go 1.13
Postgres 11
and GraphQL
I am trying to run three different queries:
1. To get details of few employees when some condition is true.
2. To get all details of all employees.
3. To ...
2
votes
0
answers
789
views
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
...
0
votes
1
answer
615
views
graphql mutation query error using graph-gophers/graphql-go package
PROBLEM
the mutation below
mutation {
signUp(signUpInput: {email: "[email protected]", username: "newUser", password: "asdfasdfawerawer"}) {
email
username
}
}
errors out the following
{...
0
votes
1
answer
665
views
The base64 hash of my node id is not what I expect
I am using the graphql-go library along with graphql-go/relay. I am trying to write some basic tests for my API, and am having some trouble with the base64 encoding mechanism. When I execute a simple ...
2
votes
1
answer
610
views
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 ...
1
vote
2
answers
2k
views
golang, creating relation between 2 model and retrieve them with Preload using gorm
I am learning golang with gqlgen and gorm as orm, I am creating an app using with 2 models user and messages where the user has a list of messages,
and the messages have sender and recipient.
I have ...
2
votes
1
answer
2k
views
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 ...
2
votes
1
answer
67
views
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
...
0
votes
1
answer
230
views
What does "graphql.NewList(type)" do?
As it turns out, graphql-go's help doc is not beginner friendly. I'm simply wondering what .NewList() does in, say, the following code: Type: graphql.NewList(types.Workouts)
1
vote
1
answer
937
views
graphql-go define field type as object
Using graphql-go how do we handle nested objects as in given api returns the following in resolver
{
id:"34",
name:"something",
region:{
id:34,
name: "San jose"
}
}
how do we implement ...
0
votes
1
answer
705
views
Mutation arguments as object
I'm using the Go implemenatation of GraphQL.
How would you configure a mutation so that it can receive arguments with more than 1 level?
For exemple, here is the list of arguments I would like to ...
1
vote
1
answer
917
views
Global variables and Go
I am currently trying to work on a small Go project, and I have a problem I am trying to solve.
I'm currently using github.com/jinzhu/gorm to handle database operations for the backend of a GraphQL ...
0
votes
1
answer
801
views
GoLang GraphQL display EOF
Im trying to made a simple GO Server that run with GraphQL and connects with PostgreSQL, the compilation and execution of the files goes well, and the connection to the database also goes well, but ...
0
votes
0
answers
434
views
Does GraphQL-go support upload file?
As the title, does GraphQL-go support upload files?
Or I must create an endpoint besides my GraphQL-endpoint to POST files?
0
votes
1
answer
883
views
Resolving list field in GraphQL without struct
I have this GraphQL type:
type User {
id: String
name: String
}
defined by
var UserObject = graphql.NewObject(graphql.ObjectConfig{
Name: "User",
Fields: graphql.Fields{
"id":...