• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

99designs / gqlgen / 19841501510
0%
master: 0%

Build:
Build:
LAST BUILD BRANCH: dependabot/go_modules/golang.org/x/text-0.37.0
DEFAULT BRANCH: master
Ran 01 Dec 2025 11:54PM UTC
Jobs 1
Files 0
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

01 Dec 2025 11:51PM UTC coverage: 0.0%. Remained the same
19841501510

Pull #3945

github

lbarthon
feat(codegen): allow users to manually extend GraphQL unions

In some scenarios, we need caching or prefetching of parts of the GraphQL query
tree. This is useful if we have a very complex tree and common fragments. This
can allow us to cache the marshalers for some fields that can appear more than
once in the schema.

We use it in a real-world scenario for lookahead fetching. A query returns IDs
of an entity, let's say, an User. For those entities, we have an extra layer
to handle visibility filtering, i.e. am I allowed to see said users (are they
blocked, hidden, restricted, etc.).
The query looks like that:
```graphql
query {
  listUsers {
    userResult {
      ... on User {
        fullname
        age
      }
      ... on UserUnavailable {
        error
      }
    }
  }
}
```

A plain GraphQL implementation, would do, in order:
- Resolve listUsers
- Resolve userResult
- Resolve the fields on the user fragment

We implement lookahead, which will do:
- Resolve listUsers
- Resolve userResult **AND** the fields on the user fragment
- Return the user fragment only if userResult is an User

Lookahead makes requests faster, at the expense of more resolver calls (thus
potentially more RPCs, DB calls, or whatever your resolvers do). We implement
it by having a different type, `LookaheadUserResult`, which is a new member of
the `UserResult` union (which can be either `User` or `UserUnavailable` in the
query above). This ensures we satisfy type requirements, however this change by
itself fails without the template changes of this commit.

This commit extends the generated code for unions: if generated union types are
returned, then we proceed with standard resolving. However, if we receive a
variant that satisfies type constraints (otherwise it won't build eh), but that
the codegen doesn't know about, check if it is a `graphql.Marshaler`, and just
return it, for the parent to call `MarshalGQL` on, as we do for all `Marshaler`!

This is the cleanest way I ... (continued)
Pull Request #3945: feat(codegen): allow users to manually extend GraphQL unions

0 of 0 relevant lines covered (NaN%)

0.0 hits per line

Jobs
ID Job ID Ran Files Coverage
1 19841501510.1 01 Dec 2025 11:54PM UTC 0
0.0
GitHub Action Run
Source Files on build 19841501510
Detailed source file information is not available for this build.
  • Back to Repo
  • Pull Request #3945
  • PR Base - master (#19824234629)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc