Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 10:23
    tschwann commented #1621
  • 10:22
    tschwann commented #1621
  • 10:21
    tschwann commented #1620
  • 09:52
    3nvi commented #1621
  • 09:40
    tschwann edited #1621
  • 09:12
    tschwann edited #1621
  • 09:11
    tschwann edited #1621
  • 09:11
    tschwann edited #1621
  • 09:08
    tschwann opened #1621
  • 07:17
    3nvi edited #1620
  • 07:17
    3nvi edited #1620
  • 07:16
    3nvi edited #1620
  • 07:14
    3nvi opened #1620
  • 02:08
    lwc closed #1534
  • 00:29
    RobertoOrtis commented #1577
  • Sep 15 22:43
    mtibben commented #268
  • Sep 15 22:36
    mtibben commented #1610
  • Sep 15 21:22
    coveralls commented #1619
  • Sep 15 21:21
    benjaminjkraft opened #1619
  • Sep 15 20:36
    tschwann closed #1618
mtatarau90
@mtatarau90
Hi guys, i have a question, is a way to get a query fields not from a rezolver, but from a middleware?
Kaarthik Rao Bekal Radhakrishna
@karthikraobr
oCtx := graphql.GetOperationContext(ctx) start, query, variables := oCtx.Stats.OperationStart, oCtx.RawQuery, oCtx.Variables
Have you tried this?
sateeshpnv
@sateeshpnv

While migrating from v0.10.2 to v0.11.3, generated.go doesn't compile:

/private/var/tmp/_bazel_sateesh/.../sandbox/darwin-sandbox/1531/execroot/__main__/bazel-out/darwin-fastbuild/bin/src/.../generated.go:4521:20: undefined: gqlparser

generated.go does not import gqlparser github.com/vektah/gqlparser/v2. However, it is used as var parsedSchema = gqlparser.MustLoadSchema(sources...)

How did the gqlparser import vanish from generated.go file?

4 replies
Erik Müller
@asterikx
Hi all, is it possible to generate only the model files? I don't need the server/resolver part as I'm using AWS AppSync. But I have some Lambdas that should use the same models.
Erik Müller
@asterikx
Is there an option to ignore "undefined" directives? I'm using @aws_cognito_user_pools (see AppSync Guide) and I want gqlgen to ignore/skip it as authentication is already handled by AppSync.
Olivier Refalo
@orefalo_gitlab
Hi.. a bit confused about gqlgen. anyways.. I tried to get the federation-demo working on the latest version with no success.
any idea?
Olivier Refalo
@orefalo_gitlab
schema.resolvers.go:43:40: ProductResolver not declared by package generated
/schema.resolvers.go:46:37: UserResolver not declared by package generated
pulling my hairs
how do I tell gqlgen to generate resolvers?!
Olivier Refalo
@orefalo_gitlab
tried with this
models:
  Query:
    fields:
      product:
        resolver: true # force a resolver to be generated
      users:
        resolver: true # force a resolver to be generated
Olivier Refalo
@orefalo_gitlab
I got it to compile by changing this:

// Product returns generated.ProductResolver implementation.
func (r *Resolver) Product() productResolver { return productResolver{r} }

// User returns generated.UserResolver implementation.
func (r *Resolver) User() userResolver { return userResolver{r} }

type productResolver struct{ *Resolver }
type userResolver struct{ *Resolver }
still the schema Query doesn't show neither Product nor User
actually... the schema doesn't have a Query type.. so I would think it's normal. ok need to sleep
Olivier Refalo
@orefalo_gitlab
ok - I got it working... at last
Simeon Miteff
@simeonmiteff
Hi There. is graphql.AddError() expected to work in subscription resolvers?
Simeon Miteff
@simeonmiteff
I'm starting a goroutine in my resolver and returning a channel and nil error (unavoidable - I need to return the channel early to get async responses), so no opportunity to pass the error via return. I add the error to the response context in the goroutine, but the resolver never sends an error down the websocket connection - it just sends a stop message.
sumanthakannantha
@sumanthakannantha
Hi there... Is there any example to use gRPC transport instead of HTTP?
Simen A. W. Olsen
@cobraz
Hello! I'm trying to build a BFF based on gqlgen and I'm having issues with using models gqlgen.yaml. I want to reference the models generated by protobuf, so that I can easily pass the result from the GRPC client. The examples are reassigning to the generated model manually, my types are larger, so it would be very much boilerplate. However, when I try to set the models in the configuration file, gqlgen command generates resolvers for all nested structs. How do avoid it? I haven't been able to turn them off, is there a trick?
Rezam
@rezam90
@javiroberts I think there is a filename_template key to set the resolver name in config file config
Rezam
@rezam90

Hi there.
I have a validate directive directive @validate(rule: String!) on INPUT_FIELD_DEFINITION.

and the directive implemention:

func validateDirective(ctx context.Context, obj interface{}, next graphql.Resolver, rule string) (res interface{}, err error) {
    res, err = next(ctx)
    if verr := validate.Var(res, rule); verr != nil {
        return nil, verr
    }

    return res, nil
}
Rezam
@rezam90
what's the best approach to have validation messages in graphql errors. I mean the fields and related errors.
Rezam
@rezam90
for now I'm returning only one field's error for a request because the directive is executed once for field and the returns. But I want to return error for multiple fields.
Jan Krynauw
@jankrynauw

Hi, I'm new here...
We currently have a graphQL server running in NodeJS and Apollo Server making use of authentication outside of the GraphQL layer. Rather than doing any authentication or authorization work in the GraphQL layer (in resolvers/models), it’s possible to simply pass through the headers or cookies to your REST endpoint and let it do the work.

// src/server.js
context: ({ req }) => {
 // pass the request information through to the model
 return {
   user,
   models: {
     User: generateUserModel({ req }),
     ...
   }
 };
},
// src/models/user.js
export const generateUserModel = ({ req }) => ({
 getAll: () => {
   return fetch('http://myurl.com/users', { headers: req.headers });
 },
});

Would something like this be possible with gqlgen and resolvers using gRPC (instead of REST)?

Sadegh
@xaoirse
hi how can i set type for model.fields?
// Defining mutation function
func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild {
    for _, model := range b.Models {
        for _, field := range model.Fields {
            field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"`
        }
        model.Fields = append(model.Fields, &modelgen.Field{
            Description: "ex",
            Name:        "ex",
            Type:        model.Fields[0].Type,
        })
    }
    return b
}
rkunhi
@rkunhi
hi all, I am getting 422 status code and no data is not found. Throws an error "Error: Objects are not valid as a React child (found: Error: Response not successful: Received status code 422). If you meant to render a collection of children, use an array instead." for a query made from Apollo client. However the query works fine in the graphql editor
jungleman13
@jungleman13_gitlab

How to efficiently implement broadcasting?

I have a Subscription that emits a new value every second. Multiple (100+) clients are subscribed to it using the same exact query.
Does gqlgen cache similar queries? If not, is it possible to have single resolver / executor / marshaler rather than one per subscribed client?

gepgecici
@gepgecici
Hello. I would like to build a modular app structure with gqlgen. For examples I will have blog and auth folder
and I would like to put all schema related to blog under blog folder
like schemas, resollvers etc
I couldn't find any example.
gepgecici
@gepgecici
?
gepgecici
@gepgecici
s
Erik Müller
@asterikx
Screenshot 2020-09-17 at 21.44.46.png
Hi all, I keep hitting the "transport not supported" error. Does anyone know what this means/how to solve it?
(I'm doing a POST)
I using Chi for routing:
func NewRouter(r *chi.Mux, h http2.AppHandler, j *jwtauth.JwtAuth) *chi.Mux {
    r.Use(middleware.RequestID)
    r.Use(jwtauth.Verifier(j))
    r.Route("/graphql", func(r chi.Router) {
        r.Handle("/", playground.Handler("GraphQL playground", "/query"))
        r.HandleFunc("/query", h.GraphQL.Handle)
    })
    return r
}
Erik Müller
@asterikx
Ah, think I found the issue, I was creating my sever using the New func (which does not add any "protocols") instead of the NewDefaultServer func (which adds a bunch of default "protocols")
Kfir Ozer
@kfirufk
can anyone provide information about the status of custom struct tags ? (99designs/gqlgen#1173) I want the types that I define will have "db":value with same value of the json hinting in order for sqlx to work with it properly
Kfir Ozer
@kfirufk
never mind i implemented it using https://gqlgen.com/recipes/modelgen-hook/
Jonatan Magnusson
@jomag_gitlab
Hey! I'm trying to add a simple custom DateTime scalar that uses RFC3339 to serialize to/from string. type DateTime time.Time.
All is fine, except I can't get gqlgen to find the type!
I have this in gqlgen.yaml:
models:
  DateTime:
    model: github.com/MyOrg/MyRepo/internal/backend/gql/gqlresolvers.DateTime
Jonatan Magnusson
@jomag_gitlab
Oh never mind! Found it: my problem was that the folder containing package "gqlresolvers" was called "resolvers".
Jonatan Magnusson
@jomag_gitlab
One thing I'm not quite sure how to handle is how data could/should be passed on to nested resolvers:
Project I'm working on has some model types, that are not the same as the model types generated by gqlgen. They are typically quite similar though, and I use mappers to translate them back and forth.