Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 05:17
    NickDubelman commented #640
  • Aug 22 12:28
    JulienBreux commented #377
  • Aug 22 09:34
    gissleh commented #840
  • Aug 22 03:00
    igtm commented #216
  • Aug 22 02:18
    bugzpodder commented #841
  • Aug 21 16:41
    thedodd commented #798
  • Aug 21 16:41
    thedodd edited #798
  • Aug 21 14:19
    apoggi-carecloud opened #844
  • Aug 21 04:32
    matiasanaya opened #843
  • Aug 21 03:43
    0xApe opened #842
  • Aug 20 19:52
    marwan-at-work commented #740
  • Aug 20 18:27
    tibraga commented #377
  • Aug 20 03:35
    vektah commented #841
  • Aug 20 02:58
    edsrzf commented #841
  • Aug 20 00:04
    vektah commented #841
  • Aug 20 00:03
    vektah commented #841
  • Aug 19 23:39
    coveralls commented #841
  • Aug 19 23:38
    edsrzf opened #841
  • Aug 19 14:47
    hboylan commented #377
  • Aug 19 12:44
    ermik commented #224
Adam Scarr
@vektah
@gissleh care to show an example, trying to work out if this is a bug and where it is?
Gisle Aune
@gissleh
The code that wasn't working is in the graphql-contrib repo, where it seems to have been possible at the one point to get the resolver context in the request middleware. https://github.com/99designs/gqlgen-contrib/blob/master/prometheus/prometheus.go#L121
Kaarthik Rao Bekal Radhakrishna
@karthikraobr
hi, I am running into a race condition which I discovered while running tests for queries. I still haven't figured out what is causing the race condition. But the race condition occurs only when one of the field resolvers returns an error. It is quite strange, I have quite a few tests for error conditions for other resolvers, but only in one of the resolvers am I running into a race condition. I tried reproducing the issue , but in vain.
Kaarthik Rao Bekal Radhakrishna
@karthikraobr
My bad. False alarm. The race condition was caused by the mocking library we are using.
Anthony Corbacho
@anthonycorbacho

Hi guys, I am new to qglgen and I am trying to understand how i can use nested resolver
I have a schema like this

schema {
  query: Query
}

type Query {
  employee(id:ID!): Employee!
  Company(id:ID!): Company!
}

" An employee "
type Employee {
  " A unique identifier. "
  id: ID!
  " The name of this person. "
  name: String!
  " The birth year of the person. "
  birthDate: String!
  " The companies this person is working at. "
  companies: [Company!]!
}

" A Company "
type Company {
  " A unique identifier. "
  id: ID!
  " The name of this company. "
  name: String!
  " The birth year of the company. "
  birthYear: Int
  " Employees working at this company "
  employees: [Employee!]!
}

But I am not able to successfully call my employees resolver with this kind of query

{
  Company(id:"42") {
    id
    employees {
      id
    }
  }
}

is there any way to do that?

this is the gist url: https://gist.github.com/anthonycorbacho/af5cd21817fd206bc89cad2a4a120790

Michael Muré
@MichaelMure
Company(id:ID!): Company! --> company(id:ID!): Company! ?
Anthony Corbacho
@anthonycorbacho

thanks for the hit, that was helpful.
I also realized that I have to put

models:
  Employee:
    model: github.com/anthonycorbacho/graphql-learning/api.Employee
    fields:
      companies:
        resolver: true

  Company:
    model: github.com/anthonycorbacho/graphql-learning/api.Company
    fields:
      employees:
        resolver: true

Instead of

model:
  filename: api/models.go
  package: api

Is there a way to autogenerate the models strut and set resolver to true?

Kiril Vladimiroff
@vladimiroff

How do you write tests for your GraphQL resolvers? Internally, we've created our own GraphQLTest type which has argument fields, handler (e.g. gqlgen/handler.GraphQL) and expected result in order to avoid repetition on do table tests.

My approach seems fairly obvious, yet I don't see any primitives for that in gqlgen nor issues demanding such. Example: https://gist.github.com/vladimiroff/d80d156917ff7868040b1e8f2db88fde

GraphQLTest.Run create net/http/httptest.Server and uses github.com/99designs/gqlgen/client.Client to send GraphQLTest.Query with applied .Variables via Client.RawPost. Unmarshals response and errors and compares them with those in GraphQLTest.

Just to help you read the example: tEnv sets up everything needed and env.schema is http.Handler made of gqlgen/handler.GraphQL with some fair amount of middlewares.

Do you find that approach of testing resolvers good?
Do you do something completely different that you find better than this?
Danny Paul
@dannypaulg_gitlab
type DirectiveRoot struct { IsAuthenticated func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) }
The directive handler has a second argument obj interface{} can someone please explain what is the purpose of this variable and what it holds?
Ghazni Nattarshah
@ghazninattarshah
Can someone share the graphql api design principles/best practices? with code generation, package structure, pagination. I am going to expose an app with graphql/mysql(gorm).
Loïc Minaudier
@lminaudier
:wave: Hello, anyone aware of an exemple of how to use gqlgen with Kafka, nats or some message bus to back subscriptions?
Aneri Shah
@AneriShah2610
Hello, can someone share me an idea how I can work with secure websocket connection for subscription.
Actually I tried subscription and it works fine on local connection over http(i.e ws://connectionURL) but when I deployed it stops working over secure connection https (i.e. wss://connectionURL).
Adam Scarr
@vektah
@AneriShah2610 need a little more to go off. It should just work
You're probably hitting cors / origin issues if the websockets are on another domain? Websockets don't follow normal cors rules
Gisle Aune
@gissleh
Is there a typo in this log line in the generation? It seems to mean the exact opposite of what it says.
EventKind has type compatible with [...]/models.EventKind
User has type compatible with string
User has type compatible with string
Aneri Shah
@AneriShah2610
@vektah Maybe It's not cors /origin issue because domain are same . It will works properly up to 3 minutes and after that it stops. Same issue like this, 99designs/gqlgen#640.
Bernd Prager
@bprager

Hi, I am running trough the gqlgen "getting-started" document and getting an error at

go run github.com/99designs/gqlgen init
go: downloading github.com/99designs/gqlgen v0.9.1
(... more downloads and extracting ...)
go: extracting golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b
unable to parse config: yaml: unmarshal errors:
  line 18: key "deprecated" already set in map
  line 20: key "include" already set in map
  line 22: key "skip" already set in map
exit status 1

I am running go version go1.12.7 darwin/amd64. Any idea what I might do wrong? Thank you!

Adam Scarr
@vektah
@bprager there is a bug in init, you can delete that directive section from the config to work around it
99designs/gqlgen#781 fix is on master but hasn't made it it a release yet will cut one today
Samuel
@IoTPanic
Hi Everyone, I'm a dev for an IoT company, and I've been using your library to create an awesome golang API. My dev John made a library inside our API called QFields that was just some really simple code that made working with this library a lot easier. Is there anyone interested in providing feedback on https://github.com/IoTPanic/gqlgen/tree/QFields before I create the pull request?
I provided an example on how they are used here https://github.com/IoTPanic/cluster-monitor-qfield-graphql-example
Adam Scarr
@vektah
Interesting, code first on top of gqlgen?
How will does mixing and matching parts in both styles work?
Samuel
@IoTPanic
I run this in production. We origonally had a python rest-like API that had 11s query times and I had to make something in 4 days. I made the decision to do a complete rewrite in golang using graphql, and the way I set it up which is similar to how you see the logic now but without qfields. And this way allowed me to only call our redis and mongo resources when the client requested the field and both John and I really liked the way I laid it out. There was a big issue though, the way I was origonally detecting fields since I was rushing and didnt understand the context system very well, didnt allow my code to say, query events after querying devices in all sites attached to the querying user.
So John made this, and if theres a better way of doing this I would like to hear it, but he added qfields so now we can query nested resoruces in resources, were currently running this in production, and itz really easy to maintain and add to.
Sorry for typos, on my phone
_legal_alien
@udayreddy
Has anyone forked the gqlgen repo and maintain their own version in their company ?
Danish Aziz Satkut
@danishsatkut
Q: Is there an agreement about generating the generated.go (gqlgen generate) as part of the CI build process OR generating it locally and adding it to source control? Does anyone have any good/bad experience with the two ways of generating code?
Adam Scarr
@vektah
@danishsatkut we generate and commit, but then get ci to check it's up to date.
Evan Shaw
@edsrzf
We do exactly the same thing
Adam Scarr
@vektah
You can use gitattributes to collapse generated stuff in prs, eg https://github.com/99designs/gqlgen/blob/master/.gitattributes
Danish Aziz Satkut
@danishsatkut
@vektah Thank you for your quick response. When you say "check it's up to date" do you mean check that the file doesn't have any modifications from the committed file during CI build? If not can you please elaborate?
Evan Shaw
@edsrzf
That's what it means in our case. Our CI runs go generate to make gqlgen regenerate code and it fails if the generated code differs from what's committed. (If git diff finds a difference, essentially.)
Adam Scarr
@vektah
Yep, what Evan said :)
Danish Aziz Satkut
@danishsatkut
@vektah @edsrzf Thank you so much :)
Herb Stahl
@ghstahl
has anyone implemented OAuth2 auth where the required claims that a query/mutation needs are configured in?
i.e.
{
"operationType": "query",
"fieldPath": "/authRequired",
"claims": [
{
"Type": "client_namespace",
"Value": "Daffy Duck"
}
]
}
{
"operationType": "query",
"fieldPath": "/findTodos/todos/user",
"claims": [
{
"Type": "a",
"Value": "b"
}
]
}
where you are required to have been authenticated but also that a claim: a=b must be present to get at the user leaf
Eric Meier
@BitPhinix
Are there any updates regarding GQLGen and Apollo Federation?
Adam Scarr
@vektah
@BitPhinix theres an update on 99designs/gqlgen#740
Evan Shaw
@edsrzf
Hello, I've created a draft PR for goroutine pooling: 99designs/gqlgen#841 I thought about opening an issue first to discuss a proposal, but the implementation ended up being simple enough that I thought code might be a clearer way to discuss it. Feedback welcome!
Evan Shaw
@edsrzf
I was looking at changing my schema to use @goModel directives rather than configuring models through gqlgen.yml. It seems like adding a @goModel directive to a type is not equivalent to specifying a model in gqlgen.yml. Is that true? Is every field individually required to have a @goField directive as well, to specify the field?
Adam Scarr
@vektah
They should be equivalent, behind the scenes it's just manipulating the config
Do you have an example @edsrzf ?
Evan Shaw
@edsrzf
I'll try to cut down a repro
(And in doing so may find that I'm completely wrong :grin: )
Evan Shaw
@edsrzf
I think I'm actually just using a version of gqlgen that's too old. Oops.