Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 30 21:25
    frederikhors closed #2264
  • Jun 30 21:25
    frederikhors commented #2264
  • Jun 30 21:19
    frederikhors closed #2265
  • Jun 30 21:19
    frederikhors commented #2265
  • Jun 30 19:47
    frederikhors commented #2198
  • Jun 30 17:51
    dball opened #2265
  • Jun 30 16:41
    StevenACoffman commented #2241
  • Jun 30 16:04
    clayne11 commented #2198
  • Jun 30 16:04
    clayne11 commented #2198
  • Jun 30 15:21
    clayne11 opened #2264
  • Jun 30 14:51
    StevenACoffman closed #2247
  • Jun 30 14:51
    StevenACoffman closed #2262
  • Jun 30 14:51
    StevenACoffman closed #2260
  • Jun 30 13:48
    visionp commented #2241
  • Jun 30 12:35
    coveralls commented #2262
  • Jun 30 11:18
    ameyarao98 commented #2207
  • Jun 30 11:14
    ameyarao98 commented #2207
  • Jun 30 11:13
    ameyarao98 commented #2207
  • Jun 30 07:45
    tabvn commented #466
  • Jun 30 06:38
    tmc edited #2263
Adam Scarr
@vektah
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
@gpopovic
Jon Lundy
@JonLundy
@ngurenyaga The only thing i can think of is that the underlying struct for Workstation has a different gotype. if Workstation.ID is not a string and say an int value it will need a way to convert to string
@ngurenyaga can you paste the struct definitions? like:
type Workstation struct{
  ID uint64
  ...
}

// vs

type Workstation struct{
  ID string
  ...
}
Goran Popovic
@gpopovic

hey guys.. im using @goField(forceResolver: true) directive to generate resolvers for relations and i have a problem
Lets say that user has a country.

In graphql its not idiomatic to have countryId, in the object, only Country.

This means that in generated resolver function (I get *generated.User) who does not have country id.

This means that i cannot easily reuse my service GetCountryById

What would be the best solution for this?
Jon Lundy
@JonLundy
in mine i usually will have somethingId along side something
i also include for Something both the id and somethingId
because id is more of a global identifier and the other is specific to the object
Cole Lawrence
@colelawrence

Is there a way to hide a field from the API user? I'm trying to achieve sort of transient data passing without needing to fully reimplement every gql model I need this for. In an optimal world, I might have something like this (see @internal):

// schema.graphql
type User {
    "id is..."
    id ID!
    "dbUser is..."
    dbUser DBUser @internal
}

scalar DBUser @goModel(model: "github.com/my/app/models.User")
// gql_models/generated.go
type User struct {
    // id is...
    id     string      `json:"id"`
    // dbUser is...
    dbUser models.User `json:"-"`
}

// resolvers/user_resolver.go
func (p userResolver) Friends(ctx context.Context, user *gql_models.User) ([]gql_models.User, error) {
    // use internal details of dbUser to resolve
    user.dbUser
    ...
}

The biggest win from this approach is that there is only one source of truth for my gql models (defined in the schema). AND we can spend time writing comprehensive documentation only once (in the schema file)

Cole Lawrence
@colelawrence
This "modelgen-hook" documentation seems relevant https://gqlgen.com/recipes/modelgen-hook/
Cole Lawrence
@colelawrence
I suppose I could do a similar approach to permission directives for now, and just always make requests fail if they request an internal field.
Cole Lawrence
@colelawrence
Is it possible to change the introspection query results based on session details? For example, could I hide fields that the current credentials don't have permission to query?
Found relevant documentation here: https://gqlgen.com/reference/introspection/ but it looks like it's just to blanket enable or disable per session
Adrien D.
@dtrckd
Hi there, is there a way to generate named return values (naked return) in the generated resolvers ?
Also, do we have access to the revolver's templates in order to auto-generate some snippets inside the revolver methods at generation time ?
Jon Lundy
@JonLundy
@dtrckd You might be talking about the modelgen-hook that @colelawrence was asking about
you can modify the generated resolvers to your liking as well. That is just a helper to get started. I imagine it will wipe out implementations if you regen them anyway
Cole Lawrence
@colelawrence
@dtrckd I don't think what you're looking for is in the model-gen hook since it only applies to model generation