Skip to content

Refactoring GraphQL - #469

Open
KBui4 wants to merge 123 commits into
graphql-v2from
graph-refactor
Open

KBui4 wants to merge 123 commits into
graphql-v2from
graph-refactor

Conversation

@KBui4

@KBui4 KBui4 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Description

Essentially applies improvements I figured out while making the GraphQL workshop.

The main change is switching from gqlgen's ID, which maps to a string type after generating, to ObjectID, a custom scalar that maps to bson.ObjectID after generating. This means we don't need all those transform functions, and we don't need to redefine DB models (e.g., we don't need both the DBCourse and Course models, just the Course model).

This also pulls the latest changes from develop, so graphql-v2 should be ready to merge into develop immediately afterwards, provided that there are no new changes in both of those branches.

List of refactoring changes:

  • Switch to using new ObjectID scalar type instead of using gqlgen's ID
  • Added custom marshaller and unmarshaller for ObjectID scalar in scalars.go
  • Deleted db_models.go since we don't need separate DB models and transform functions anymore, and removed db_models_test.go since we no longer need the tests for transform functions
  • Added models.go for manually defining models with ID reference; gqlgen will use these models instead of regenerating them because of the autobind option in gqlgen.yml
  • Edited all the resolvers and dataloaders to get them working due to the above
  • Removed tests for professor dataloader; those are unnecessary since we no longer convert from hex string to ObjectID and vice versa
  • Moved from forcing resolvers in gqlgen.yml to using the inline directive in the schema; I think it's easier to do it this way compared to adding it at the end of the configuration file, and also, I don't really want people messing around with gqlgen.yml if not necessary
  • Edited generate command in build.bat to use go tool for gqlgen generate instead of using a direct path as recommended from gqlgen
  • Added generate command to Makefile

Testing

  • Ran REST and GraphQL through all the checks, tests, and built it.
  • Manually tested a few REST API endpoints and a few GraphQL queries.
  • Ran both generate commands.

AI Disclosure

This was more for when I was doing it for the GraphQL workshop but just for adding and using the custom marshaller and unmarshaller for the ObjectID scalar.

Checklist

  • Create this PR
  • Perform final self-review

justinschwerdtfeger and others added 30 commits August 19, 2026 10:23
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.83.1 to 1.83.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.83.1...v1.83.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.83.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
…olang.org/grpc-1.83.2

Bump google.golang.org/grpc from 1.83.1 to 1.83.2
Initialize Sentry with the DSN from the environment instead of a
hardcoded value. An unset SENTRY_DSN leaves the DSN empty, which the
SDK handles by installing a no-op transport, so development
environments stop reporting to Sentry without needing SENTRY_DSN=""
in every contributor's .env.
config(sentry): Read the Sentry DSN from SENTRY_DSN
Add unit tests for GetPortString, GetEnvMongoURI, GetClubsDBUri,
GetEnvLogin, GetEnvLimit and GetEnvMaxUploadSize, covering the unset,
parsed, unparseable and hard-capped paths.

GetEnvMongoURI and GetEnvLogin end in log.Fatalf, which would take the
test binary down with them, so those cases run in a subprocess and
assert the exit code. The subprocess runs from an empty directory so a
contributor's own .env cannot satisfy the variable under test.
fix: return 404 for missing section course (#433)
test(configs): Cover the remaining env reading functions
@KBui4
KBui4 marked this pull request as ready for review November 14, 2026 22:37
@KBui4

KBui4 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

I think I'll leave it so gqlgen autobinds to /graph/model for now. I'll look into binding with the REST schema models once I get to figuring out what to do with events.

a-avad and others added 24 commits November 16, 2026 10:19
replace mock ids with valid ids in tests
Issue 445 CLUBS_DB_URI Optionality
…eturn-the-available-terms

382 create the endpoint that return the available terms
#401 Fixed all minor golangci-lint errors + integrated golangci-lint into CI/CD
Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.45.0 to 1.47.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.45.0...v1.47.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-version: 1.47.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
…elemetry.io/otel/sdk-1.47.0

build(deps): bump go.opentelemetry.io/otel/sdk from 1.45.0 to 1.47.0
@KBui4
KBui4 requested a review from a team as a code owner November 30, 2026 02:51
golangci-lint defaults to 3 issues max so if there's more than 3 issues, you'd have to run the lint command multiple times

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.