Tag: gqlgen
-
How to make sure my graphql subscription api is working?
0 This is my subscription resolver in golang: func (r *subscriptionResolver) CreateChatWithBot(ctx context.Context, req model.CreateChatWithBotRequest) (<-chan *model.CreateChatWithBotResults, error) { ch := make(chan *model.CreateChatWithBotResults) testString := []string{"This", "part", "is", "under", "construction", "…", " Be", "patient", "please!"} go func() { defer close(ch) for _, v := range testString { select { case <-ctx.Done(): return case ch <-…
-
How do you mask sensitive request params in gqlgen?
1 I am currently using gqlgen and would like to log request parameters for error investigation purposes. While I know how to access request parameters like below, I am concerned that this way may log sensitive information such as email addresses or passwords. srv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error { goc := graphql.GetOperationContext(ctx) fmt.Println(goc.Variables) // i…
-
How to properly implement GraphQL resolvers
1 I am creating a basic Graphql project. In this project I am only fetching user details. The data is stored in database. Here is the GQL schema: type User { id: ID! username: String! email: String! age: Int address : String firstname: String lastname :String } type Query { getUserById(id: ID!): User } When…
-
gqlgen: Code Generation Fails When Binding Types: “Unable to bind to interface”
0 I am facing an issue with gqlgen’s code generation in my Go project. I have a GraphQL schema and a Go interface where I’m trying to bind a type CourseProduct to a Go struct. However, I’m encountering an error during the code generation process. Here’s a snippet of my GraphQL schema: interface Product @goModel(…
-
Custom error status code with gqlgen + go gin
2 Recently I have been updating my GO REST APIs into graphQl API’s and I came across issue where I am unable to customise my status code with gqlgen. Response I got Headers Status Code: 200 OK { data: null, errors: [ {message: "Unauthorized access", path: ["…"]} ] } Expected Header Status Code: 401 UNAUTHORISED…
-
How to generate GraphQL query from protocol buffer generated code with gqlgen?
0 I have a protocol buffer file which includes an enumeration within a message. message Advisor { … enum AdvisorRole { // here be values } } This pb is the input to generate stubs using protoc-gen-gogo. ../gen/ProjectService.pb.go type Advisor_AdvisorRole int32 const ( // here be constant values ) The generated code is in time…
-
GqlGen incorrectly generates directives that have colon character in value field
0 I use https://github.com/99designs/gqlgen for generating golang code from graphql schema. I need to be able to add gorm tags to the resulting golang types. For that, I declare a directive for custom go tags (in schema.directives.gql): directive @goTag( key: String! value: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION Then I use it the following way…
-
How to resolve “Error fetching schema” in gqlgen
2 Good day, i am new to go and i am trying to build a graphql service with go, i did this using the go gqlgen package. Now when install and generate necessary files the initial start up, i can see the default TODO schema and resolver on the docs tab, when i implement or…