Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 17 23:20
    mtibben commented #1664
  • Oct 16 18:00
    numToStr commented #1664
  • Oct 16 17:58
    efectn commented #1664
  • Oct 16 17:57
    frederikhors edited #1664
  • Oct 16 17:57
    frederikhors commented #1664
  • Oct 16 17:57
    frederikhors edited #1664
  • Oct 16 17:55
    efectn commented #1664
  • Oct 16 17:52
    frederikhors commented #1664
  • Oct 16 17:50
    frederikhors edited #1662
  • Oct 16 17:49
    frederikhors opened #1664
  • Oct 16 07:10
    wilhelmeek commented #1663
  • Oct 16 06:55
    negz commented #1663
  • Oct 16 03:13
    wilhelmeek closed #1585
  • Oct 16 03:13
    wilhelmeek commented #1585
  • Oct 16 02:00
    wilhelmeek closed #1663
  • Oct 16 02:00
    wilhelmeek closed #1547
  • Oct 16 01:44
    StevenACoffman commented #1652
  • Oct 16 01:40
    StevenACoffman commented #1663
  • Oct 15 23:58
    wilhelmeek edited #1663
  • Oct 15 23:57
    coveralls commented #1663
Jon Lundy
@JonLundy
np
cpunekar
@cpunekar
just for general knowledge.. what's the folder structure you guys follow for production servers?
Jon Lundy
@JonLundy
I typically have
  • pkg/generated/generated.go
  • pkg/model/model_gen.go
  • pkg/resolvers/...go
Just to keep them separate
I have seen in examples where the generated/models are subdirectory of resolvers
cpunekar
@cpunekar
@JonLundy that makes more sense.. thanks!
Tassios Marios
@mariosttass
Hi guys,
Basically I have a simple question, in case that we have a very complicated schema there is a work around to generate that using gqlgen library?
Thank you.
Jon Lundy
@JonLundy
@mariosttass how do you mean?
like its a large schema? or there are many interconnected types and queries?
Tassios Marios
@mariosttass
  Hi, I was meaning that in case that there are many types and queries. 
Jon Lundy
@JonLundy
is it failing to generate the source files?
Tassios Marios
@mariosttass
No, basically I am asking if there is a way to generate the schema from structs.
Jon Lundy
@JonLundy
ah.. i think some of the other projects for graphql do some things like that. this project is designed around the other way, taking a schema and building a server for it.
Thunder is an example of a struct first approach https://github.com/samsarahq/thunder
Tassios Marios
@mariosttass
Thank you very much @JonLundy
Slava
@m0sth8
Hi. Is it possible to use resolver in Go code to get json object? I have a use case when I need to return graphql object via rpc channel.
Slava
@m0sth8
Seems like I can do this with an Executor exposed in 0.11
Jon Lundy
@JonLundy
Graphql typically returns a json object for requests. Do you mean having the json embedded in a value?
Like {"res":"{\"a\":1}"}
Julien
@juleur
hi
is someone encounter problems with extensions errors ?
Tassios Marios
@mariosttass
Hi guys,
I have a question, I am using gqlgen library with gorm library and I want to use only one model, how I can setup the gqlgen to use the already defined model ?
Thanks !
David Douglas
@ddouglas

Hello All, been using GQLGen for a while now. Just started a fresh project today and I am getting the following error when generating the schema.

validation failed: packages.Load: -: no matching versions for query "latest"

I did some research and i think this is an error from a dependency of gqlgen

Any tips?
Andy Grunwald
@andygrunwald
Hey everyone,

First, thanks a lot for this awesome project. It helps a lot and makes a lot of fun.
I am curious, is there support for multiple GraphQL Schemas? I am not talking about splitting your Schema into multiple files. I am talking about two GraphQL schemas. One intended for a public interface and one for a backend service (e.g., an admin dashboard).
In an admin dashboard, you typically want to expose more data than in the public interface. The scenario is also described here: https://spectrum.chat/graphql/general/splitting-a-graphql-api-between-public-private~d84a2d9c-e052-422f-aedc-21c0ecc642eb

An alternative would be to create a second service from scratch and keep it 100% independent. Con here would be code duplication or it is getting tricky to share code/models.
E.g.

Client ---> Public GraphQL Service ---> Database <--- Private GraphQL Service <---Backend/Admin-Dashboard

How do you think about this?
Let me know (also if this is the wrong place to ask and I should open a feature request to support multiple schemas in one instance)

Andy Grunwald
@andygrunwald
I opened up an issue to discuss this: 99designs/gqlgen#1126
Adrien D.
@dtrckd
Hello. Is it possible to access a Resolver object from within a directive handle ?
I only see the parameter next graphql.Resolver...
Adrien D.
@dtrckd
...or the gqlgen Config object (which typically contains the Resolvers) ?
Adrien D.
@dtrckd
... As I am asking about directives management, I take this opportunity to ask, do the directive function handlers are executed in parallel ? What would be a good approach to use object shared by all the handlers, and call a final method when all directives passed to kind of "reduce" the result ?
John Forstmeier
@forstmeier

Hi everyone, I've getting started using gqlgen and I had a couple questions on configuration:

  • Under what circumstances is a schema.resolvers.go file generated?
  • Is it possible to control the naming/location of this output file?
  • Where can I find an example YML file that contains all of the settings options available? E.g. other options for the resolver.layout: follow-schema field.

I also have just a general question on GraphQL:

  • Is there a way to set a default value for one of the fields on an input type? E.g. with two mutations one for creating a user on an application having the default role set to USER and another where a user is created as part an org being created in which case their role is set to ADMIN.
weeee9
@weeee9
hello, does anyone know how to test authentication with client ? the recipe example get the user's information from context, but I can't find a function to set client context.
Jeremy Reed
@jpreed00
Hi all, is there an example somewhere about how to modularize schemas/graphql functions, etc.? The use case is I have two customers, A and B. I want to have a "core" API module that contains shared functionality, such as authorization, 2 factor authentication, password resets, etc. Then, I want to extend this core (or somehow include it) into the separate APIs for customers A and B, each having different requirements and so on.
The idea is that any changes to the "core" module, would be reflected in the API for both customer A and customer B without having to maintain a completely separate codebase.
Jordan Lucier
@jlucier

Hello all, I'm using gqlgen with a Dgraph database and the fields on types I've defined in Dgraph end up with names like User.email instead of just email which is not reflected in the schema graphql files.

Thus, in order to unmarshal json from Dgraph responses, I either can't use the Golang structs gqlgen generates for me or I have to modify them (by adding User. in front of the json hints). This seems rather cumbersome, so I'm curious if anyone has thoughts or solutions. I hope I haven't missed something out there in docs somewhere (if I have, a link would be awesome).

Kashif Shaikh
@kashifshaikh_twitter
Hi everyone - I wanted to test how gqlgen would work for big schemas - I used the Github public schema - but it SIGSEGVs after generating the models. The reason I’m doing this, is that I want to create a service where ppl upload there schemas and I would auto-generate or scaffold resolvers with simple mapping to DBs, Etc.
ankurbaglodi
@ankurbaglodi
Hi All, Are there any examples where I can see how GqlGen - GraphQL server written with tests? I am trying to write integration tests for the GraphQL Server in my repo. Any pointers will be helpful :)
Adrien D.
@dtrckd
@jlucier Hi am building a backend that use gqlgen as the Business Logic Layer and Graphql-Dgraph as the database. I use a source schema to feed the Graphql-Dgraph endpoint and the same one for gqlgen by basically appending the query, mutation and input generated by Grraphql-Dgraph into the source schema. Like this, I can follow the request from gqlgen to Dgraph and backward, by marshalling request and response and whithout the need to append the class name. (and by using custom resolver to translate the request in/out.
John Forstmeier
@forstmeier

Can anyone explain how ctx would be set in the "TODO" example?
https://github.com/99designs/gqlgen/blob/master/example/todo/todo.go#L37

For example, if I'm running this "TODO" example app locally and I want to query the done field for the todo owned by them, how would I pass in the them ID?

Max Weston
@Maxweston
hey all, don't suppose anyone would know why generate.go would be generating an import incorrectly to "github.com/vektah/gqlparser/v2/ast" to call the method MustLoadSchema, after fishing through the vendor files i have found that this method exists in the root folder of the dependancy.
sateeshpnv
@sateeshpnv

Any is a scalar that maps to interface{} go type - https://gqlgen.com/reference/scalars/#any.

This is preventing usage of github.com/gogo/protobuf/types.Any . go run gqlgen fails with panic: interface conversion: types.Type is *types.Signature, not *types.Named

What is the alternative?

2 replies
Liam Ross
@liamross

I'm having a lot of trouble implementing even basic logging (other than top level logging on chi which has no insight into the actual graphql requests), and I'm wondering if anyone is able to point me towards some docs or examples.

I've seen people link to the prometheus package, but that is outdated, and I don't know how the now non-existent RequestMiddleware maps to the new OperationMiddleware vs ResponseMiddleware, or what the difference between those are. If someone has a modern example, or is able to clear up when I should use OperationMiddleware vs ResponseMiddleware, and how to translate the dated prometheus example (I wouldn't mind implementing prometheus, but obviously would need to rewrite the package in order for it to work with modern gqlgen) that would be really appreciated!

1 reply
Kirill Tatchihin
@rbUUbr

hi everyone, I meet with issue while upgrading my resolvers from 1 file to follow-schema. Every time I run "go run github.com/99designs/gqlgen generate" all my files are recreating :( here is my gqlgen.yml:

# .gqlgen.yml example
#
# Refer to https://gqlgen.com/config/
# for detailed .gqlgen.yml documentation.

#GraphQL Schemas
schema:
  - "graph/*.graphql"

exec:
  filename: "graph/generated/gql.go"
  package: gql

resolver:
  layout: follow-schema
  dir: graph
  type: resolver

model:
  filename: models/generated.go
autobind: []

expected: after running go run github.com/99designs/gqlgen generate as it was in old mechanism with one resolver

alexander ikeh
@AlexSwiss

You don’t need to specify the resolver in the yml file before you can follow the schema.

Just write your schema in your .graphl file then run

go run github.com/99designs/gqlgen

It will generate your schema resolver file and also the model file to follow your schema
Kirill Tatchihin
@rbUUbr
yep, but after generation of resolvers, I would like to add field to schema. I add it, run:
go run github.com/99designs/gqlgen
and then see that all my files inside of graph directory regenerated, how can I make it to not regenerate existing files?
alexander ikeh
@AlexSwiss

After you modify the schema, delete the schema.resolver file before you run

go run github.com/99designs/gqlgen