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?
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 *
I have a bit of a mystery here:
The generated ResolverRoot
interface looks like this:
type ResolverRoot interface {
Query() QueryResolver
Mutation() MutationResolver
}
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?
type Workstation struct{
ID uint64
...
}
// vs
type Workstation struct{
ID string
...
}
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