Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 05 23:57
    StevenACoffman closed #2315
  • Aug 05 23:36
    neptoess commented #2315
  • Aug 05 23:31
    neptoess commented #2315
  • Aug 05 23:30
    neptoess ready_for_review #2315
  • Aug 05 23:29
    StevenACoffman commented #2315
  • Aug 05 23:24
    coveralls commented #2315
  • Aug 05 23:24
    coveralls commented #2315
  • Aug 05 23:23
    neptoess converted_to_draft #2315
  • Aug 05 23:21
    neptoess opened #2315
  • Aug 05 20:41
    StevenACoffman closed #1469
  • Aug 05 20:41
    StevenACoffman closed #2314
  • Aug 05 20:18
    StevenACoffman commented #2314
  • Aug 05 20:05
    coveralls commented #2314
  • Aug 05 18:54
    neptoess commented #2314
  • Aug 05 18:49
    neptoess synchronize #2314
  • Aug 05 18:45
    neptoess synchronize #2314
  • Aug 05 18:39
    neptoess commented #2314
  • Aug 05 16:51
    neptoess commented #2314
  • Aug 05 16:47
    neptoess commented #2314
  • Aug 05 16:29
    neptoess synchronize #2314
Adam Scarr
@vektah
:D
I cant help but feel like thats a dig at the gqlgen docs. Doc writing is hard, its a whole different skillset for sure
and unlike code/tests, they dont break when they fall out of date
Jimmy
@kejiro
:) No, not really, haven't had any major issues with those docs, but a lot of, especially javascript and java, packages it's easier to read the code to see what something does than try to get it from the docs.
But it's true, documentation is not easy, I can't say that I'm very good at it either. But with godoc and it's documentation so close to the code at least it's easier than a completely separate document, even it's not perfect.
Adam Scarr
@vektah
yeah, go is the perfect language for jump-to-definition
which means theres no place better for your docs
Muhammad
@harmnot
did u know why I can't go list ? because my main package was another folder ,
@vektah
g
@SimplyKnownAsG

Hi I'm looking to use the feature introduced in 99designs/gqlgen#375. I am forced to use a single version of mapstucture (the latest) and it has caused errors in slices_test.go. gqlgen is on an older version, upgrading mapstructure in gqlgen will break the tests. The code asserts Test1 []string and Test3 []*string should resolve to nil and [] respectively. The newer version of mapstructure will return nil for all or [] for all depending on the value of ZeroFields.

Does this test have anything to do with the feature (always use pointers in resolver return types)? Do you know what errors having the different versions might cause?

Adam Scarr
@vektah
375 shouldnt affect that
Adam Scarr
@vektah
with json encoding an empty slice becomes [] and a nil becomes null, gqlgen does some magic on top for fields that are [Foo]!, as null doesnt make sense for them, so they always return [] regardless
as far as inputs go, it doesnt matter, a nil slice is len() == 0
g
@SimplyKnownAsG
where does gqlgen do something on top for non-null fields? I do not see that in client/client.go
Adam Scarr
@vektah
in the generated code
client is just used for testing
g
@SimplyKnownAsG
Thanks for that. I'll have to look into it to better understand. in that case, is the error during testing when upgrading mapstructure a false positive?
g
@SimplyKnownAsG
If I wanted to do a PR to update mapstructure, should I change the test or change the client?
Adam Scarr
@vektah
First I would check that the raw json from gqlgen isn't changing, then make the test work whichever way matches closest to the json representation
My biggest concern is going to be around peoples internal uses of mapstructure, as a version bump (unless they did a major) will also push along all other uses
Ethaniel Rubio
@ethanrubio
i'm trying to understand the dataloaden library and how to best utilize it. i find my users via an external API, so I can query for them directly by userID but in the examples of dataloaden, all the users are loaded in instead. should I be following this pattern using this external API? it allows for searching of all users in a similar manner, but that seems a little weird to me when I just want to cache the api response so that it can be reused in child resolvers similar to how it's done here https://graphql.org/blog/rest-api-graphql-wrapper/.
Adam Scarr
@vektah
That's one of the jobs of the dataloader, it's assuming that a batch fetch I'd much cheaper. If your API can't do batch your probably better off with a simple cache instead
Sven Roeterdink
@swennemans
Is there any documentation/examples about logging? I'm trying to log both graphql errors but also server errors (for example: database errors). Or is the default using the ApolloTracer?
Alireza Salary M.N
@arsmn
Is it possible to access field collection for input object?
Kirill Tatchihin
@rbUUbr
hi there! I want to measure time duration for each field's resolving. Is there some builtin ways to do it?
Adam Scarr
@vektah
@swennemans take a look at AroundFields on the handler - https://gqlgen.com/recipes/migration-0.11/
@rbUUbr same to you
@arsmn no, inputs dont get collected. thats part of the response (output type, not input type) handling - see http://spec.graphql.org/June2018/#sec-Field-Collection
Kirill Tatchihin
@rbUUbr
@vektah great, thanks! updated version, really great updates, now handler looks pretty and without a lot of methods
Julien
@juleur
hi all, does something change about errors since 0.11 ? I cant return Extensions custom errors anymore
Bhaskar Saraogi
@bhaskarsaraogi_twitter
Hi, trying to find how to define a custom JSON scalar in gqlgen(something on the lines of, https://github.com/taion/graphql-type-json) ?
scalar Map doesnt work exactly, becuase marshalling primitve json like 0 or "some string" fails
Adam Scarr
@vektah
@bhaskarsaraogi_twitter are you looking for Any?
@juleur lots of things changed, if you have a more concrete example I can take a look
Julien
@juleur
now, its returning the message only (extensions are left out)
Julien
@juleur
?
Andreas Backx
@AndreasBackx
Does anyone know whether the context from the federated gateway is propagated in gqlgen? I cannot find any documentation on it and following what a request goes through is a bit hard. https://www.apollographql.com/docs/apollo-server/federation/implementing/#sharing-context-across-services
Andreas Backx
@AndreasBackx
Oh wow, I looked straight over the fact that you need to do that manually. My apologies.
sateeshpnv
@sateeshpnv
Any suggestions on splitting generated.go into smaller files? I have a repo with a 256kB size restriction per file.
sateeshpnv
@sateeshpnv

Any suggestions on splitting generated.go into smaller files? I have a repo with a 256kB size restriction per file.

Render() function at https://github.com/99designs/gqlgen/blob/master/codegen/templates/templates.go#L61 looked like the code that can be refactored to split a single generated.go into multiple files. However, looking at a generated.go file for one query, biggest region is field.topl and this region alone can cross 256KB.

1: 21 // region ** generated!.gotpl **
2: 1666 // region * args.gotpl *
3: 1726 // region ** directives.gotpl **
4: 1730 // region ** field.gotpl *
5: 7009 // region ** input.gotpl *
6: 7031 // region ** interface.gotpl *
7: 7035 // region ** object.gotpl **
8: 8348 // region * type.gotpl *

Goran Popovic
@gpopovic
Hey guys..Is it possible to pass somehow through context from parent resolver to child? generated model is passed, but i would like to pass something else
an example viewer pattern... i would like all resolvers that are generated on top of viewer to have (full internal user) available
Jon Lundy
@JonLundy
so .. you want the user for the current request to be passed along?
yes. if you set the user in the context it should be available to the other resolvers. As long as it takes place first.
I usually set it in the context before it is passed on to the graphql handler
Ngure Nyaga
@ngurenyaga

I have a bit of a mystery here:

App 1

The generated ResolverRoot interface looks like this:

type ResolverRoot interface {
    Query() QueryResolver
    Mutation() MutationResolver
}

App 2

In addition to the Mutation() MutationResolver and Query() QueryResolver that I expected, there are several more interfaces e.g

type ResolverRoot interface {
    // a bunch of interfaces elided
    Workstation() WorkstationResolver
}

These extra interfaces define some of the behaviour of a Relay "node" (generation of object identifiers) e.g

type WorkstationResolver interface {
    ID(ctx context.Context, obj *Workstation) (string, error)
}

Both apps' GraphQL schemata look similar. For both, I was trying to implement a Relay spec-compliant API.

The first app (the one that did not generate the extra interfaces and behaved as I expected) has a schema that looks like this:

interface Node {
  id : ID!
}

enum SortOrder {
  ASC
  DESC
}

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

type Organization implements Node {
  id: ID!
  name: String!
  sladeCode: String!
}

type OrganizationEdge {
  cursor: String
  node: Organization
}

type OrganizationConnection {
  edges: [OrganizationEdge]
  pageInfo: PageInfo!
}

input OrganizationFilterInput {
  search : String
  name: String
  sladeCode: String
}

input OrganizationSortInput {
  name: SortOrder
  sladeCode: SortOrder
}

# a bunch of similar types have been elided

type Query {

  listOrganizations(
    first: Int, after: String, last: Int, before: String,
    filter: OrganizationFilterInput, sort: OrganizationSortInput): OrganizationConnection!

  findOrganization(id: ID!): Organization!

  # A bunch of fields elided here too
}

The schema in the second app follows the same patterns.

The mystery is - what caused the second app to generate all these extra interfaces?

I am on gqlgen v0.11.2. What should I look at?

Goran Popovic
@gpopovic
@JonLundy but im talking about adding something in a resolver to the context ..since you're not returning context..how can other resolver get it? It doesnt make sense
Jon Lundy
@JonLundy
the context is a pointer. so changes to it will exist upstream