diff --git a/.env.template b/.env.template index 27962beb..9bdce2fd 100644 --- a/.env.template +++ b/.env.template @@ -13,6 +13,8 @@ CLUBS_DB_URI= # SENRTY SENTRY_ENVIRONMENT=development +# Leave unset outside of production -- an empty DSN disables Sentry +SENTRY_DSN= # For Google Cloud Routes /storage /email (internal use only) GOOGLE_APPLICATION_CREDENTIALS= diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 00000000..69e118f1 Binary files /dev/null and b/.github/.DS_Store differ diff --git a/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml new file mode 100644 index 00000000..da72b156 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml @@ -0,0 +1,47 @@ +name: 🪲 Bug Report +description: File a bug report +type: Bug +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this bug report! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + - type: textarea + id: description + attributes: + label: Description + description: What is the bug? + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps To Reproduce + description: Help us reproduce this bug. If helpful, you can include screenshots or logs! Be sure to wrap logs with ```` ```bash ```` before and ```` ``` ```` after. + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Describe the bug in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help. + validations: + required: false + - type: dropdown + id: version + attributes: + label: Version + description: Where did you find this bug? + options: + - api.utdnebula.com + - a local development branch + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: What environment were you using when you encountered this bug? + value: | + API Client: + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..b1ad4507 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: General Contact + url: https://about.utdnebula.com/about/contact + about: Get in touch here diff --git a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml new file mode 100644 index 00000000..13a15dfe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml @@ -0,0 +1,28 @@ +name: 💡 Feature Request +description: Suggest an idea for this project, e.g., a new feature, an improvement to an existing feature, or a new integration +type: Feature +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this feature request! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + - type: textarea + id: problem + attributes: + label: Problem + description: What's the problem this feature would solve? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Solution + description: Describe your preferred solution to this problem. Include any alternative solutions or features you've considered if applicable. Include screenshots or designs if they would help + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Describe the feature in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/internal_issue_template.yml b/.github/ISSUE_TEMPLATE/internal_issue_template.yml new file mode 100644 index 00000000..b8dc0685 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/internal_issue_template.yml @@ -0,0 +1,28 @@ +name: 🔧 Internal Change +description: Suggest an internal change, e.g., documentation, dependencies, a code refactor +type: Task +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this internal change suggestion! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + - type: textarea + id: problem + attributes: + label: Problem + description: What's the problem this change would solve? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Solution + description: Describe your preferred solution to this problem. Include any alternative solutions or features you've considered if applicable. Include screenshots or designs if they would help + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Describe the change in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help + validations: + required: false diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..2dfbbc29 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ + + +### Description + + + + +### Testing + + + + +### AI Disclosure + + + + +### Checklist + + +- [x] Create this PR +- [ ] Perform final self-review diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml new file mode 100644 index 00000000..38d21aff --- /dev/null +++ b/.github/workflows/wiki.yml @@ -0,0 +1,27 @@ +name: Publish Wiki + +on: + push: + branches: [develop] + paths: + - 'docs/**' + workflow_dispatch: + +concurrency: + group: publish-wiki + cancel-in-progress: true + +permissions: + contents: write + +jobs: + publish-wiki: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Sync docs to GitHub Wiki + uses: Andrew-Chen-Wang/github-wiki-action@v5 + with: + path: docs/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2c72ca40..ad5ae3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,12 @@ bin/ go.work go.work.sum +# semesters json +semesters.json + # API executables rest-api -graph-api \ No newline at end of file +graph-api + +# mac +**/.DS_Store diff --git a/Makefile b/Makefile index c791b865..45081edd 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,13 @@ setup: go install honnef.co/go/tools/cmd/staticcheck@latest go install golang.org/x/tools/cmd/goimports@latest go install github.com/swaggo/swag/cmd/swag@latest + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 format: go mod tidy gofmt -w . goimports -w . + golangci-lint run ./... --max-issues-per-linter 0 --max-same-issues 0 check: go mod tidy @@ -47,6 +49,11 @@ docs-rest: docs: docs-rest +generate: + cd graphql && go get -tool github.com/99designs/gqlgen@latest + cd graphql && go tool gqlgen generate + go mod tidy + build-rest: docs-rest go build -o $(REST_EXEC_NAME) ./rest diff --git a/README.md b/README.md index df891496..ddff435e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,18 @@ _A database for some really useful UTD data collected by our [tools](https://git Project maintained by [Nebula Labs](https://about.utdnebula.com). -## Documentation +## Quick Navigation + +- [API Documentation](https://api.utdnebula.com/swagger/index.html) +- [Developer Wiki](docs/Home.md) +- [Getting Started Guide](/docs/Getting-Started.md) +- [Project Architecture](/docs/Project-Architecture.md) +- [Project Structure](/docs/Project-Structure.md) +- [Contributing Guide](/docs/How-to-Contribute.md) +- [Troubleshooting & FAQ](/docs/Troubleshooting.md) +- [Discord Community](https://discord.utdnebula.com) + +## API Documentation Documentation for the current production API can be found [here.](https://api.utdnebula.com/swagger/index.html) @@ -21,82 +32,8 @@ Contributions are welcome! This project uses the MIT License. -Please visit our [Discord](https://discord.utdnebula.com) and talk to us if you'd like to contribute! Don't be afraid to ask for help! - -### How to Contribute - -Create your own fork by [forking this repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository) - -[Clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) your forked repository. (Don't forget to install Git if you haven't already) - -Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) - -## Repository Structure - -- `rest/` - REST API service implementation -- `internal/` - Shared schemas, models, and utilities across services -- `Makefile` & `build.bat` - Root-level build and development scripts - -## Building -### Requirements -- [Golang 1.26 or Higher](https://go.dev/dl/) - -### Building for Windows - -Setup Go Dependencies with: -```cmd -.\build.bat setup -``` - -Build with: -```cmd -.\build.bat build -``` - -This will create an executable named `rest-api.exe` in the root directory. - -Run with: -```cmd -.\rest-api.exe -``` -> Note: Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. - -### Building for macOS, Linux, and WSL - -Setup Go dependencies with: -```bash -make setup -``` - -Build with: -```bash -make build -``` - -This will create an executable named `rest-api` in the root directory. - -> Note: If Make fails with "swag: No such file or directory" or similar, you may need to add GOPATH/bin to your path. On Mac/Linux, use `echo 'export PATH=${PATH}:'$(go env GOPATH)'/bin' >> ~/.zshrc && source ~/.zshrc` (or `.bashrc`) to add it permanently. - -Run with: -```bash -./rest-api -``` - -## Running API locally -Copy `.env.template` to `.env` with: -```bash -cp .env.template .env -``` - -Enter Nebula MongoDB URI in `.env` (ask for help in the [Discord](https://discord.utdnebula.com)) - -Run `rest-api`: -```bash -./rest-api -``` - -Check command output to see the route serving traffic. It's likely port 8080. +Please visit our [Developer Wiki](docs/Home.md) to get started! -Visit `http://localhost:8080` to access nebula-api locally. +## Community & Support -> Storage and email routes require additional environment variables. If you're working on these routes, ask for help in the [Discord](https://discord.utdnebula.com) +Have questions, suggestions, or want to contribute? Reach out on our [Discord](https://discord.utdnebula.com)! diff --git a/build.bat b/build.bat index 13febd06..a4a3007c 100644 --- a/build.bat +++ b/build.bat @@ -49,6 +49,8 @@ go install golang.org/x/tools/cmd/goimports@latest if ERRORLEVEL 1 exit /b %ERRORLEVEL% go install github.com/swaggo/swag/cmd/swag@latest if ERRORLEVEL 1 exit /b %ERRORLEVEL% +go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 +if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo Setup done! echo. exit /b 0 @@ -85,16 +87,12 @@ go vet ./... if ERRORLEVEL 1 exit /b %ERRORLEVEL% staticcheck ./... if ERRORLEVEL 1 exit /b %ERRORLEVEL% -set "GOFMT_FILES=" -for /f "delims=" %%F in ('gofmt -l .') do ( - set "GOFMT_FILES=1" -) -if defined GOFMT_FILES exit /b 1 -set "GOIMPORTS_FILES=" -for /f "delims=" %%F in ('goimports -l .') do ( - set "GOIMPORTS_FILES=1" -) -if defined GOIMPORTS_FILES exit /b 1 +gofmt -w . +if ERRORLEVEL 1 exit /b %ERRORLEVEL% +goimports -w . +if ERRORLEVEL 1 exit /b %ERRORLEVEL% +golangci-lint run ./... --max-issues-per-linter 0 --max-same-issues 0 +if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo Checks done! echo. exit /b 0 @@ -156,12 +154,12 @@ exit /b 0 :generate echo Generating GraphQL execution layer... pushd graphql -go get github.com/99designs/gqlgen@latest +go get -tool github.com/99designs/gqlgen@latest if ERRORLEVEL 1 ( popd exit /b %ERRORLEVEL% ) -go run github.com/99designs/gqlgen generate +go tool gqlgen genreate if ERRORLEVEL 1 ( popd exit /b %ERRORLEVEL% diff --git a/docs/Getting-Started.md b/docs/Getting-Started.md new file mode 100644 index 00000000..16ec4612 --- /dev/null +++ b/docs/Getting-Started.md @@ -0,0 +1,152 @@ +# Getting Started with Nebula API + +Here's how to set up your local development environment. + +## Prerequisites + +Ensure you have the following installed: + +- Git - For version control + - If you've never used git, need a refresher, or need help setting it up, please check out [Nebula's Git Workshop](https://github.com/UTDNebula/git-workshop). +- Go - For building and running + - You can install from the [Go website](https://go.dev/dl/), or from [Homebrew](https://brew.sh/) or another package manager for automatic updates +- Make _(Linux/macOS)_ - For build automation + - Pre-installed on macOS (via `xcode-select --install`) and most Linux distributions (`build-essential`) +- Docker _(Optional)_ - For running containerized runners locally + +**Make** is a build automation tool. Feel free to check out [`Makefile`](../Makefile) to see exactly what's being run. + +If you're using Windows, instead of using `make`, you can also use our [`build.bat`](../build.bat) file. When you see any command starting with `make`, you can instead use `.\build.bat`. +For example instead of `make setup`, you can run `.\build.bat setup`. + +## Local Setup + +### Clone the Repository + +Clone the repository with `git clone`, and then, `cd` into the project directory or open it in your preferred code editor. + +**HTTPS:** + +```bash +git clone https://github.com/UTDNebula/nebula-api.git +cd nebula-api +``` + +or + +**SSH:** + +```bash +git clone git@github.com:UTDNebula/nebula-api.git +cd nebula-api +``` + +Now open the cloned project in your code editor! + +### Install Development Tooling + +Install the Go static analysis and formatting tools (`staticcheck` and `goimports`): + +```bash +make setup +``` + +or + +```cmd +.\build.bat setup +``` + +If you installed **Go** with [**Homebrew**](https://brew.sh/), you need to add Go tools to your path for tools like `staticcheck` and others to work. + +- **For zsh** (the default shell on MacOS) + + ```bash + echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.zshrc && source ~/.zshrc + ``` + +- **For bash** (the default shell on most Linux distributions) + + ```bash + echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.bashrc && source ~/.bashrc + ``` + +- **For fish** + + ```bash + echo 'fish_add_path (go env GOPATH)/bin' >> ~/.config/fish/config.fish + ``` + +### Configure Environment Variables + +First, make a file called `.env` at the root of the project. + +Then, copy the contents of `.env.template` into it. Some parts in `nebula-api` require certain environment variables, which you can fill in `.env`. + +If you're not sure what to put, please try contacting one of our members through [Discord](https://discord.utdnebula.com). + +> [!IMPORTANT] Do NOT put any environment variables into `.env.template`. + +### Run Code Verification & Formatting + +Check your code with: + +```bash +make check +``` + +or + +```cmd +.\build.bat check +``` + +You'll want to run this frequently while developing. + +### Build the CLI Executable + +Compile the Go source code into a runnable binary (`./rest-api` on Linux/macOS, `rest-api.exe` on Windows): + +```bash +make build +``` + +or + +```cmd +.\build.bat build +``` + +### Verify with Automated Tests + +Run the test suite to confirm your environment is ready: + +```bash +make test +``` + +or + +```cmd +.\build.bat test +``` + +If all tests pass, congratulations! Your local development environment is ready. + +### Running the API locally + +To run `rest-api` locally, use: + +```bash +./rest-api +``` + +Check command output to see the route serving traffic. It's likely port 8080. + +Visit `http://localhost:8080` to access nebula-api locally. + +> [!NOTE] Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. + +## Next Step + +Now that your environment is running, it's time to dive deeper. Check out [Project-Architecture.md](Project-Architecture.md) diff --git a/docs/Home.md b/docs/Home.md new file mode 100644 index 00000000..477ac7ad --- /dev/null +++ b/docs/Home.md @@ -0,0 +1,17 @@ +# Nebula API Developer Documentation + +Welcome to the **Nebula API Developer Documentation**! + +These docs are intended for developers of `nebula-api` rather than users. For usage instructions, see [README.md](../README.md). + +If you are a new developer, check out the pages under "Getting Started" in the Sidebar! + +## Need Help? + +Join [our community on Discord](https://discord.utdnebula.com) and ask questions in the `#api-help` or the development channels. We are always happy to help! + +## Found something you want to change on these docs? + +Don't edit these docs manually on Github. Instead, suggest a change by [creating an issue](https://github.com/UTDNebula/nebula-api/issues), or [opening a pull request](https://github.com/UTDNebula/nebula-api/pulls) with your changes. + +These docs are automatically generated from the `docs/` folder of this repository. diff --git a/docs/How-to-Contribute.md b/docs/How-to-Contribute.md new file mode 100644 index 00000000..62ead237 --- /dev/null +++ b/docs/How-to-Contribute.md @@ -0,0 +1,60 @@ +# How to Contribute + +Thank you for your interest in contributing to `nebula-api`! Here's how to contribute to our project. +Don't worry if you don't quite know what you're doing, we're here to help. We don't expect perfection and appreciate anything you can do to help! + +## Find something to work on + +Look at our current issues, or make your own on our [issues page](https://github.com/UTDNebula/nebula-api/issues). + +For beginner issues, please write the code yourself rather than using AI to generate it. These issues are designed to help new members learn the codebase and build familiarity with the project. We allow AI in Nebula Labs, but review our [AI Policy](https://nebula-labs.atlassian.net/wiki/spaces/NLG/pages/1135607810/AI+Policy) for more information on acceptable uses of AI. + +Once you find an issue, write a comment asking if you can work on it. + +If you're unsure about something, **don't hesitate to ask for help**. We're happy to answer questions and help you work through issues. You can reach out on GitHub, Discord, or in person. + +## Create a branch + +Nebula recruits and members should make their changes on a branch, external contributors should work off of a fork as they do not have permission to make a branch. + +## Make Your Changes + +It's time to code! + +Don't forget to format and check your code. We have helper scripts with **Make** and **build.bat**: + +Check your code with + +```bash +make check +``` + +or + +```cmd +.\build.bat check +``` + +Run tests with + +```bash +make test +``` + +or + +```cmd +.\build.bat test +``` + +We would appreciate if you make a draft Pull Request as your working on it, so we can see your progress and help you out! + +## Making a Pull Request (PR) + +Open [our Pull Request Page](https://github.com/UTDNebula/nebula-api/pulls), and create a PR. If you're not finished, you can make your PR a draft. + +Maintainers will review your PR and may provide suggestions or request changes before approval. + +## Next Step + +You have everything you need to start, but do feel free to check out other pages first. diff --git a/docs/Project-Architecture.md b/docs/Project-Architecture.md new file mode 100644 index 00000000..602dc9d7 --- /dev/null +++ b/docs/Project-Architecture.md @@ -0,0 +1,115 @@ +# API Architecture + +Nebula API provides UTD data for others to use, including information on courses, professors, events, and more. + +## API Overview + +Here's a quick look at Nebula API. + +### REST API + +The Nebula API is a RESTful API. [What's an API? What does RESTful mean?](https://aws.amazon.com/what-is/restful-api/) + +Currently, the Nebula API offers data for the following through its endpoints: + +- Courses +- Professors +- Sections +- Grades +- Comet Calendar Events +- Mazevo Events +- Astra Events +- Club Events - provided by UTD Clubs +- Rooms +- Discounts + +Docs for each of these endpoints can be found on [Our REST API Swagger page](https://api.utdnebula.com/swagger/index.html), which is generated from comments in the code. + +> [!NOTE] +> Nebula API powers only UTD Trends and UTD Rooms. UTD Clubs and Notebook have their own API internal to their own projects. In addition, the Clubs endpoints are powered by the internal Clubs database. + +All of this information (except for the clubs endpoints) is gathered with [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. + +### How does Nebula REST API work? + +When a user sends a HTTP request, [Gin](https://gin-gonic.com/) handles the request by matching the URL request to one of our routes. For example, if a user sends a `GET` request to `https://api.utdnebula.com/course`, that request goes to the course route, found in `rest/routes/courses.go`. + +Then, Gin passes the request's arguments to the appropriate controller (in `rest/controllers`). These arguments are used for filtering and limiting data, so the user gets exactly what they want. + +The controller uses those arguments with Mongo's Go Driver to construct a query filter and execute it against the Mongo database. This process gets the user the exact data they requested. + +The Mongo database then fetches the requested data with filters and returns the data back to the controller. The controller sends the data back to Gin. The controller can also provides Gin an HTTP status code indicating the requests outcome (such as if it was successful). + +Gin creates a HTTP response with the data and HTTP status code. + +Finally, Gin sends the HTTP response back to the user. + +### API Diagram + +``` mermaid +flowchart LR + A[User] --HTTP Request--> B + B[Gin] --*gin.Context--> C + C[Controllers] --"Constructed + Query Filter"--> D + D[("Mongo + Database")] + D --Requested Data--> C + C --"Data and + Status Code"--> B + B --HTTP Response--> A +``` + +## API Documentation + +We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes from comments in the code. + +If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. + +## Languages and Core Technologies + +### Golang + +[Tour of Go](https://go.dev/tour/welcome/1) - Start here if you're new to Golang. +[Effective Go](https://go.dev/doc/effective_go) - Guide for writing clear Golang code. +[Go Documentation](https://go.dev/ref/spec) - For more technical details about Golang. + +The main language we use for Nebula API and the API tools. + +### MongoDB + +[Go Mongo Driver Documentation](https://www.mongodb.com/docs/drivers/go/current/) - For using MongoDB with Golang. + +Nebula API stores the majority of its data in a MongoDB database. We interact with the Mongo database with the Mongo Go driver. + +## Libraries + +### Gin + +[Documentation](https://gin-gonic.com/en/docs/) - For more information regarding Gin. + +Gin is a HTTP web framework for Golang that allows to build the Nebula API. + +### Swagger + +[Our API Docs](https://api.utdnebula.com/swagger/index.html) - Generated by Swagger. + +[Documentation](https://swagger.io/docs/) - For more information regarding Swagger. + +Swagger is responsible for auto-generating our documentation for our API endpoints. + +### Sentry + +[Documentation](https://docs.sentry.io/get-started/guides/) - Sentry for Golang. + +Sentry provides performance and error monitoring to help us find and fix problems. + +### Google Cloud + +[Documentation](https://pkg.go.dev/cloud.google.com/go#section-readme) - Google Cloud Services for Golang. + +We use Google Cloud for our email and storage endpoints. + +## Next Step + +See [Project-Structure.md](Project-Structure.md) diff --git a/docs/Project-Structure.md b/docs/Project-Structure.md new file mode 100644 index 00000000..a4f6c097 --- /dev/null +++ b/docs/Project-Structure.md @@ -0,0 +1,31 @@ +# Project Structure + +This file provides a brief overview of important directories and files. + +```text +nebula-api/ +├── .github/ # Configuration for the GitHub repo. Used for GitHub workflows. +├── docs/ # Pages for developer wiki documentation. +├── rest/ # Directory for our RESTful API endpoints. +│ ├── configs/ # Congfiguration to set up for endpoints. +│ ├── controllers/ # Main part of API. Handles HTTP requests and responds to them. +│ ├── docs/ # Auto-generated docs on API routes from Swagger. +│ ├── responses/ # Was used for cloud storage endpoints. No longer used. +│ ├── routes/ # Defines all possible API routes. +│ ├── schema/ # Defines structure for the data. Shared with api-tools. +│ ├── Dockerfile # Configuration for building a container image for Nebula API. +│ └── server.go # Initializes API endpoints +├── .env.template # Template for environment variables used in this project. +├── .gitignore # For specifying files we do not want GitHub to track. +├── build.bat # For building Nebula API on Windows. +├── go.mod # For Go dependencies. +├── go.sum # Also for Go dependencies. +├── Makefile # For building Nebula API on Mac and Linux. +├── README.me # Documentation mainly for users of Nebula API. +├── update-gateway.bat # For updating the API gateway configuration on Windows. +└── update-gateway.sh # For updating the API gateway configuration on Mac or Linux. +``` + +## Next Step + +See [How-to-Contribute.md](How-to-Contribute.md) diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md new file mode 100644 index 00000000..423b96da --- /dev/null +++ b/docs/Troubleshooting.md @@ -0,0 +1,15 @@ +# Troubleshooting + +Here are some solutions to common problems. + +## KEY is missing from .env + +Ensure you have filled environment variables in the .env file. If you need guidance on how to set up .env, please ask for help. + +## Port 8080 is already in use + +Close applications that might use port 8080 (e.g., Steam). If you're not sure which process is currently using port 8080, please ask for help. + +## Still Stuck? + +Ask for help on [Discord](https://discord.utdnebula.com)! \ No newline at end of file diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md new file mode 100644 index 00000000..0fb15416 --- /dev/null +++ b/docs/_Sidebar.md @@ -0,0 +1,10 @@ +## Getting Started + +- [Getting Started](Getting-Started.md) +- [Project Architecture](Project-Architecture.md) +- [Project Structure](Project-Structure.md) +- [How to Contribute](How-to-Contribute.md) + +## References + +- [Troubleshooting](Troubleshooting.md) \ No newline at end of file diff --git a/go.mod b/go.mod index f2410dd7..2d53ab0e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,8 @@ go 1.26.0 require ( cloud.google.com/go/storage v1.65.0 - github.com/99designs/gqlgen v0.17.95 + github.com/99designs/gqlgen v0.17.98 + github.com/fsouza/fake-gcs-server v1.56.1 github.com/getsentry/sentry-go v0.48.0 github.com/getsentry/sentry-go/gin v0.48.0 github.com/gin-gonic/gin v1.12.0 @@ -13,10 +14,9 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 - github.com/vektah/gqlparser/v2 v2.5.37 + github.com/vektah/gqlparser/v2 v2.5.64 github.com/vikstrous/dataloadgen v0.0.10 - github.com/wneessen/go-mail v0.8.1 - go.mongodb.org/mongo-driver/v2 v2.9.1 + go.mongodb.org/mongo-driver/v2 v2.10.0 google.golang.org/api v0.293.0 ) @@ -28,11 +28,12 @@ require ( cloud.google.com/go/compute/metadata v0.9.0 // indirect cloud.google.com/go/iam v1.13.0 // indirect cloud.google.com/go/monitoring v1.30.0 // indirect + cloud.google.com/go/pubsub/v2 v2.6.2 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.60.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/agnivade/levenshtein v1.2.1 // indirect + github.com/agnivade/levenshtein v1.2.2 // indirect github.com/bytedance/sonic/loader v0.5.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.7 // indirect @@ -41,7 +42,7 @@ require ( github.com/envoyproxy/go-control-plane/envoy v1.39.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.3.3 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect - github.com/go-jose/go-jose/v4 v4.1.4 // indirect + github.com/go-jose/go-jose/v4 v4.1.6 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v1.0.0 // indirect @@ -50,40 +51,46 @@ require ( github.com/go-openapi/swag/pools v0.29.1 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/goccy/go-yaml v1.19.2 // indirect + github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.21 // indirect github.com/googleapis/gax-go/v2 v2.24.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/pkg/xattr v0.4.12 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.61.0 // indirect github.com/sosodev/duration v1.4.0 // indirect github.com/spiffe/go-spiffe/v2 v2.8.1 // indirect + github.com/urfave/cli/v3 v3.14.0 // indirect + go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect - go.opentelemetry.io/otel v1.45.0 // indirect - go.opentelemetry.io/otel/metric v1.45.0 // indirect - go.opentelemetry.io/otel/sdk v1.45.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect - go.opentelemetry.io/otel/trace v1.45.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/sdk v1.47.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/oauth2 v0.36.0 // indirect golang.org/x/time v0.15.0 // indirect - golang.org/x/tools v0.49.0 // indirect + golang.org/x/tools v0.52.0 // indirect google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect - google.golang.org/grpc v1.83.1 // indirect + google.golang.org/grpc v1.83.2 // indirect ) require ( - cloud.google.com/go/cloudtasks v1.19.0 github.com/bytedance/gopkg v0.1.4 // indirect github.com/bytedance/sonic v1.15.2 // indirect github.com/gabriel-vasile/mimetype v1.4.15 // indirect @@ -100,7 +107,7 @@ require ( github.com/goccy/go-json v0.10.6 // indirect github.com/jackc/pgx/v5 v5.10.0 github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.19.2 // indirect + github.com/klauspost/compress v1.20.3 // indirect github.com/klauspost/cpuid/v2 v2.4.0 // indirect github.com/leodido/go-urn v1.5.0 // indirect github.com/mattn/go-isatty v0.0.24 // indirect @@ -109,16 +116,17 @@ require ( github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.3.2 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.2.0 // indirect + github.com/xdg-go/scram v1.4.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect golang.org/x/arch v0.30.0 // indirect - golang.org/x/crypto v0.55.0 // indirect - golang.org/x/mod v0.40.0 // indirect - golang.org/x/net v0.58.0 // indirect - golang.org/x/sync v0.22.0 // indirect - golang.org/x/sys v0.47.0 // indirect - golang.org/x/text v0.41.0 // indirect + golang.org/x/crypto v0.58.0 // indirect + golang.org/x/mod v0.42.0 // indirect + golang.org/x/net v0.61.0 // indirect + golang.org/x/sync v0.24.0 // indirect + golang.org/x/sys v0.49.0 // indirect + golang.org/x/text v0.43.0 // indirect google.golang.org/protobuf v1.36.12 // indirect ) + +tool github.com/99designs/gqlgen diff --git a/go.sum b/go.sum index 2813c28b..47726b1e 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,12 @@ cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0= cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.123.0 h1:2NAUJwPR47q+E35uaJeYoNhuNEM9kM8SjgRgdeOJUSE= cloud.google.com/go v0.123.0/go.mod h1:xBoMV08QcqUGuPW65Qfm1o9Y4zKZBpGS+7bImXLTAZU= cloud.google.com/go/auth v0.23.2 h1:pxSCpfiji41hpzpPdMCftEUCezpgpqmmDdYiAjCKXxo= cloud.google.com/go/auth v0.23.2/go.mod h1:4DhBRcqvtljQN3dJ57qtqbib5ZGCYE5f2crfiiC2EM0= cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= -cloud.google.com/go/cloudtasks v1.19.0 h1:+RK0lPIB6TlcBP7JyqmmhCNihp1Iw4QQ8uxcvlKhBVQ= -cloud.google.com/go/cloudtasks v1.19.0/go.mod h1:8q8wNubq0jFvXW5Pz8P3O7QWJBXOmfrY918FqTgIqHA= cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs= cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10= cloud.google.com/go/iam v1.13.0 h1:ufT3FPT5rFFXu6UtLkNoxaOaV5EuA1dsSkmemCSTo6U= @@ -18,12 +17,15 @@ cloud.google.com/go/longrunning v1.2.0 h1:WjYH3YHBGCxGJP9M4dWGHBfXr/cFIjMkNgWcJj cloud.google.com/go/longrunning v1.2.0/go.mod h1:5KMQALFGOCtFoi2xSOA1u3H7WKlhmckgiyFw7+LGQp0= cloud.google.com/go/monitoring v1.30.0 h1:r/d+JUbyKmJ8b07iznuKfzVzrIXTWxHQ3lBRm3x2LlY= cloud.google.com/go/monitoring v1.30.0/go.mod h1:htlUR0QWVMrjFzZmN4LGnMAve9xB/eduwjmINxVZ8RM= +cloud.google.com/go/pubsub/v2 v2.6.2 h1:YPeEXnf4LZz9eVdpbXqBMRlxdwk4breCUsoIp7uDet4= +cloud.google.com/go/pubsub/v2 v2.6.2/go.mod h1:JaFvWNVRk3Knoil/4M1ECeLOaI9D8drbmJWypQlK5aM= cloud.google.com/go/storage v1.65.0 h1:McbFt5j+hTNx+dkFuzq7teakIKcpqGp/cJZRxMyfvAc= cloud.google.com/go/storage v1.65.0/go.mod h1:UsS9OgFg/XHOSYakQ8ZtLWWeyGkk1WnmD/GsGfN0BHM= cloud.google.com/go/trace v1.16.0 h1:GmQovzFc5F0CNfl0VLgL64aoTtu7xsM0YajW2GlG9+E= cloud.google.com/go/trace v1.16.0/go.mod h1:r+bdAn16dKLSV1G2D5v3e58IlQlizfxWrUfjx7kM7X0= -github.com/99designs/gqlgen v0.17.95 h1:882h7F5iJImgtyUVttc4MOK2NbzbMYc2oyNeHqkjpP4= -github.com/99designs/gqlgen v0.17.95/go.mod h1:kHYPrpwOXDU1OQyxIg3Z7nVXSnlUoHVWBY7CMJCAM4M= +github.com/99designs/gqlgen v0.17.98 h1:t7UTlygkXMx1tJmKyR0LxttcufXnJ7fF6fAaeHSofAc= +github.com/99designs/gqlgen v0.17.98/go.mod h1:tIoiUl+cgIT7nayvObZkKDgplxd1pHcUAmEXAyv+8f4= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0 h1:3SdxXLkgAfiHRWcGTq6fneq9jgoJzneiY0yPQnjoT2E= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0/go.mod h1:1iIdl0k+ppn9wT0wzR9H7HkSvIui/4qgtnKW10cQtds= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 h1:HldzheTs05E3ybqSitI/wHaof6+XERRudgZLjYbs3eE= @@ -34,8 +36,8 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.60.0/go.mod h1:SRAbhyZ4R4FagHMM9VtRgSY/lheRoht2fKelZXQUenk= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM= -github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= +github.com/agnivade/levenshtein v1.2.2 h1:fI8RgiztYX1Nn5pBHHqQ9EMCCklhrmXqPRIedFmx5M4= +github.com/agnivade/levenshtein v1.2.2/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM= @@ -44,10 +46,13 @@ github.com/bytedance/sonic v1.15.2 h1:90H+rcF/FwLXwfB1cudOLq/je83n683Utf4Cbp0xHC github.com/bytedance/sonic v1.15.2/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA= github.com/bytedance/sonic/loader v0.5.2 h1:0QtP1gevc1OZ6/H8Lb9BRZiCXd1Ftjd3OKuj1T1lBIo= github.com/bytedance/sonic/loader v0.5.2/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI= github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2 h1:aBangftG7EVZoUb69Os8IaYg++6uMOdKK83QtkkvJik= github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2/go.mod h1:qwXFYgsP6T7XnJtbKlf1HP8AjxZZyzxMmc+Lq5GjlU4= github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA= @@ -58,16 +63,24 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo= github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA= github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU= github.com/envoyproxy/go-control-plane/envoy v1.39.0 h1:1uwRDYPYG8BIBU9Mj1sUAebNmlM6beu/ZKKweSLDxk8= github.com/envoyproxy/go-control-plane/envoy v1.39.0/go.mod h1:5e4ylfTZO723MEEFsCpSW4ZEBWR8mwkEyXfwJBTCZ9c= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.3.3 h1:MVQghNeW+LZcmXe7SY1V36Z+WFMDjpqGAGacLe2T0ds= github.com/envoyproxy/protoc-gen-validate v1.3.3/go.mod h1:TsndJ/ngyIdQRhMcVVGDDHINPLWB7C82oDArY51KfB0= github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= +github.com/fsouza/fake-gcs-server v1.56.1 h1:K03sAvbLvDz4hAynpCCUqnNRp+ik9JFSvHbkD/wTPOU= +github.com/fsouza/fake-gcs-server v1.56.1/go.mod h1:rzibfBNKouMLeVYDkIDqUiCEcfgDyJWe+4PhG7uesmU= github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI= github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ= github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY= @@ -82,8 +95,8 @@ github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8= github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA= -github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= +github.com/go-jose/go-jose/v4 v4.1.6 h1:sNRkftxFJxwsILiQukqp5z83QBSmntVwmgRY7AqBDO4= +github.com/go-jose/go-jose/v4 v4.1.6/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -130,21 +143,48 @@ github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU= github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= +github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= +github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.21 h1:OFdQ3tnCX/zaQ0Cedur3D3z7kI6HiLX9g3TiAN4/DFU= github.com/googleapis/enterprise-certificate-proxy v0.3.21/go.mod h1:L3D/IQExI6LqEjBdXcZQ1WluSgigQmSwBboFstVPM4w= github.com/googleapis/gax-go/v2 v2.24.0 h1:myMaPYyF9MecEmvQqMqomIwn9t/4KCZN9qnwsS76wlg= github.com/googleapis/gax-go/v2 v2.24.0/go.mod h1:IaTHBDd7NHxSCiu0vEs8pQZu4dGZrWwuSoxCnk16OFM= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= @@ -159,14 +199,22 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8= -github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= +github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw= github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU= +github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM= +github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw= github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0= github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE= github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI= github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= +github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI= +github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= +github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= +github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= +github.com/minio/minio-go/v7 v7.3.0 h1:HM4pFCSQq/TK+j0/zmorSh5ddh81iDgRgU0BG0Vz/YU= +github.com/minio/minio-go/v7 v7.3.0/go.mod h1:KUPWdecEO1LWyUz+sTGXAuf2jZHrPh5fCsRH86QbPfk= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -174,19 +222,26 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/xattr v0.4.12 h1:rRTkSyFNTRElv6pkA3zpjHpQ90p/OdHQC1GmGh1aTjM= +github.com/pkg/xattr v0.4.12/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6ktU= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0= github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk= github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII= github.com/quic-go/quic-go v0.61.0 h1:ui88A53s8MSVYLC56en0KQ17HARk+9986Dn0SBfKNvA= github.com/quic-go/quic-go v0.61.0/go.mod h1:9So2anK4Tp22URSQq00k+Vo2PNkle96ycDPDHL4s9vs= +github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/sosodev/duration v1.4.0 h1:35ed0KiVFriGHHzZZJaZLgmTEEICIyt8Sx0RQfj9IjE= github.com/sosodev/duration v1.4.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spiffe/go-spiffe/v2 v2.8.1 h1:eXZMLsu+3MLEPJyGJkolqtVrteZfQdUpOWj6LTiDl/E= @@ -199,6 +254,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= @@ -209,27 +265,31 @@ github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw= github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI= github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg= +github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ= +github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= -github.com/vektah/gqlparser/v2 v2.5.37 h1:jbb1Ilv+xBklV6653tKb4oVUupPNTLb5LmrnBKVI12Y= -github.com/vektah/gqlparser/v2 v2.5.37/go.mod h1:9O4Ox6Ngd3Y12bMD3w6i3CRQXh8W1oC1q0m6olCymDM= +github.com/urfave/cli/v3 v3.14.0 h1:a8414NQlHJs0c/iBsulKLzlES0n/lEAskbL2LKpU4/s= +github.com/urfave/cli/v3 v3.14.0/go.mod h1:vXn6HxPNccJSzQr2QvwVncOKrgYGIHU0HY5h8B2nQj4= +github.com/vektah/gqlparser/v2 v2.5.64 h1:N32yM6hQ6Kd5RdjCCEJsUrbCebVoA9yLLMOIa88Mkk0= +github.com/vektah/gqlparser/v2 v2.5.64/go.mod h1:nILRSUbsWDTuf8hSmAgFxuYh0SaMZdkvl6JSEbkJX8g= github.com/vikstrous/dataloadgen v0.0.10 h1:x07XAeEjIWXohvcjRvE72KY8pV5A3sTbKEFmxcj9RNM= github.com/vikstrous/dataloadgen v0.0.10/go.mod h1:8vuQVpBH0ODbMKAPUdCAPcOGezoTIhgAjgex51t4vbg= -github.com/wneessen/go-mail v0.8.1 h1:tVcncj02/QySVFw3zr/kXOzZcuFQqBNT6K+Rbgm/pcM= -github.com/wneessen/go-mail v0.8.1/go.mod h1:dWZ61zadzCIyvB4y1/YzC5O7MrbbzBfPkARmbosdf8w= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.2.0 h1:bYKF2AEwG5rqd1BumT4gAnvwU/M9nBp2pTSxeZw7Wvs= -github.com/xdg-go/scram v1.2.0/go.mod h1:3dlrS0iBaWKYVt2ZfA4cj48umJZ+cAEbR6/SjLA88I8= +github.com/xdg-go/scram v1.4.0 h1:3/wY9vMc786lAsuowR1CGxl0oVQDUWnCliDnWKhiZJs= +github.com/xdg-go/scram v1.4.0/go.mod h1:rWC+ac5XyfRhG8rI7Css3P9K+/sjzldRjM9PI7VPlNM= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver/v2 v2.9.1 h1:jewiFs2m1/VOQp8qhFshX6hWZ+EAXDhZHXExAUMcOgQ= -go.mongodb.org/mongo-driver/v2 v2.9.1/go.mod h1:SHKN0IWkKmEVGHLjXnni6s4wPKX4v86FTgOeJJFuXcA= +github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs= +github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s= +go.mongodb.org/mongo-driver/v2 v2.10.0 h1:BYJLuVSu3/xDvToG+VQyoTPS+jxq9tuQDf+1nAlFKSE= +go.mongodb.org/mongo-driver/v2 v2.10.0/go.mod h1:PxPyIAlsI1jkYZvUNfTr++ggyBP+RSaxHYctt6TcZc4= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/detectors/gcp v1.45.0 h1:9jR0ZPRok9ryaOQ2Wx8rg5F7Aon59mxrqbVI60/vlBk= @@ -238,20 +298,22 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.7 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0/go.mod h1:DqEFwLumhzMBDQv9PcWbyoDxHI/4lAk6CM4nJBH39sc= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 h1:LMuyCAyfalSjDyjdC65nK6N0zoTT63+E/u95X0JovZI= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0/go.mod h1:085m8qbm4hgc8rZWGDEa4vmyyo2c3nPxUslYUKUIU04= -go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU= -go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 h1:hqxVTu/GtBF+vJ8d1fzW7fRxZFvgoDjWcxwwCaFDYpU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0/go.mod h1:z5fVEF4X5v0ESvlJqBrrFlBVoj5EQuefZpzsu7R+x5Q= -go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M= -go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s= -go.opentelemetry.io/otel/metric/x v0.67.0 h1:PcicCNZFkZ4bXfSooXdo3WN7RBOVOtjVdo1wD358Uns= -go.opentelemetry.io/otel/metric/x v0.67.0/go.mod h1:FBjCWZe6wgcqxcMtjdGiClDKXb2YxxXii0CXftE4QtI= -go.opentelemetry.io/otel/sdk v1.45.0 h1:4VVSMgQ83dUgW2aoX5f6JgLvHwIvzcuLnF9lUdCSpCw= -go.opentelemetry.io/otel/sdk v1.45.0/go.mod h1:Sr40LgXV7DsKMMJMKOhUWOgMWTfAaqvm2kF0g7ilwuA= -go.opentelemetry.io/otel/sdk/metric v1.45.0 h1:oVFszMfyj1Am6s24Vtc7wBb8BKLcwepJjNEYILuiE3o= -go.opentelemetry.io/otel/sdk/metric v1.45.0/go.mod h1:vUWUxDZvu1WVRj8JA8S0AdhsPrZoDpA2DdZauIh4mDA= -go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag= -go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= +go.opentelemetry.io/otel/metric/x v0.69.0 h1:DjRLr15H83v+hCW7JA9NoJvOkYTtmq5YoDRbe9deYpM= +go.opentelemetry.io/otel/metric/x v0.69.0/go.mod h1:uVvsMPMFFyj/HUQfrUnH3JjnOQ1dwFDorgFLRBasM0k= +go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I= +go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0= +go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw= +go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= @@ -261,32 +323,50 @@ go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/arch v0.30.0 h1:sB9h+1gRGa2+LauFSV0tm8bK1J2yo1bx6/Uyi/P6DTU= golang.org/x/arch v0.30.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= -golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= +golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= -golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= +golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg= +golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= -golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= +golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw= +golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= -golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= +golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= -golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= +golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -295,30 +375,58 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= -golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= -golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= +golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= +golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/api v0.293.0 h1:p9XIWOf63U4OgYx120ZwVU8+vl4XTPmWfgVPnmOAS9w= google.golang.org/api v0.293.0/go.mod h1:6n5tjEB1gzwniZTepZ0g5u+wM7Bof5GeULCx/zh8ZE0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688 h1:2ficYAs+4TBEqohUu9hr7J2YeNTie+3BVyqERjs5Hm0= google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688/go.mod h1:icDJeJwWhZtQDn/1WGql+0n01hbizh4G7/T75RoxcHs= google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI= google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= -google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y= -google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.67.3 h1:iM9Lhz5MRSGhHVGGwCuzG9KO8PoirCXj/m/qTmOJJQw= +gopkg.in/ini.v1 v1.67.3/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml index 05ee6fdc..d0818c49 100644 --- a/graphql/gqlgen.yml +++ b/graphql/gqlgen.yml @@ -121,7 +121,7 @@ call_argument_directives_with_null: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: -# - "graphql/graph/model" + - "./graph/model" # This section declares type mapping between the GraphQL and go type systems # @@ -161,26 +161,6 @@ models: Any: model: - github.com/99designs/gqlgen/graphql.Any - - # Forcing field resolvers - Course: - fields: - sections: - resolver: true - - Section: - fields: - course_reference: - resolver: true - professors: - resolver: true - - Professor: - fields: - sections: - resolver: true - - SectionWithTime: - fields: - section: - resolver: true \ No newline at end of file + ObjectID: + model: + - github.com/UTDNebula/nebula-api/graphql/graph/model.ObjectID \ No newline at end of file diff --git a/graphql/graph/comet_calendar.resolvers.go b/graphql/graph/comet_calendar.resolvers.go index f597e1e6..dbb73af4 100644 --- a/graphql/graph/comet_calendar.resolvers.go +++ b/graphql/graph/comet_calendar.resolvers.go @@ -35,7 +35,7 @@ func (r *queryResolver) CometCalendars(ctx context.Context, filter *model.CometC if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() var calendars []*model.CometCalendar if err = cursor.All(timeoutCtx, &calendars); err != nil { @@ -69,17 +69,13 @@ func (r *queryResolver) CometCalendars(ctx context.Context, filter *model.CometC } // CometCalendar is the resolver for the CometCalendar field. -func (r *queryResolver) CometCalendar(ctx context.Context, id string) (*model.CometCalendar, error) { +func (r *queryResolver) CometCalendar(ctx context.Context, id bson.ObjectID) (*model.CometCalendar, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - var calendar model.CometCalendar - err = r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}).Decode(&calendar) + + err := r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": id}).Decode(&calendar) if err != nil { if errors.Is(err, mongo.ErrNoDocuments) { return nil, fmt.Errorf("calendar not found: cannot find collection") diff --git a/graphql/graph/course.resolvers.go b/graphql/graph/course.resolvers.go index a087cb91..76f908c8 100644 --- a/graphql/graph/course.resolvers.go +++ b/graphql/graph/course.resolvers.go @@ -18,10 +18,9 @@ func (r *queryResolver) Courses(ctx context.Context, filter *model.CourseFilter, defer cancel() var courses []*model.Course - var dbCourses []*model.DBCourse // Build the mongo query from the filter's struct - var courseQuery bson.M + courseQuery := bson.M{} if filter != nil { bsonBytes, err := bson.Marshal(filter) if err != nil { @@ -39,37 +38,30 @@ func (r *queryResolver) Courses(ctx context.Context, filter *model.CourseFilter, if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() - if err = cursor.All(timeoutCtx, &dbCourses); err != nil { + // Unmarshal into courses + if err = cursor.All(timeoutCtx, &courses); err != nil { return nil, err } - // Transform Mongo course to GraphQL course - for _, dbCourse := range dbCourses { - courses = append(courses, model.TransformCourse(dbCourse)) - } - return courses, err } // Course is the resolver for the course field. -func (r *queryResolver) Course(ctx context.Context, id string) (*model.Course, error) { +func (r *queryResolver) Course(ctx context.Context, id bson.ObjectID) (*model.Course, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } + var course model.Course + var err error - var dbCourse model.DBCourse - result := r.CourseCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(&dbCourse); err != nil { + result := r.CourseCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(&course); err != nil { return nil, err } - return model.TransformCourse(&dbCourse), err + return &course, err } // Sections is the resolver for the section field referenced from course diff --git a/graphql/graph/events.resolvers.go b/graphql/graph/events.resolvers.go index c9ed9187..f01f4e56 100644 --- a/graphql/graph/events.resolvers.go +++ b/graphql/graph/events.resolvers.go @@ -6,6 +6,7 @@ import ( "time" "github.com/UTDNebula/nebula-api/graphql/graph/model" + "github.com/UTDNebula/nebula-api/graphql/loaders" "go.mongodb.org/mongo-driver/v2/bson" ) @@ -14,19 +15,18 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - var dbEvents model.DBMultiBuildingEvents var events *model.MultiBuildingEvents - err := r.EventCollection.FindOne(timeoutCtx, bson.M{"date": date}).Decode(&dbEvents) + err := r.EventCollection.FindOne(timeoutCtx, bson.M{"date": date}).Decode(events) if err != nil { return nil, err } - events = model.TransformMultiBuildingEvents(&dbEvents) if building == nil { return events, nil } + events = &model.MultiBuildingEvents{} for _, b := range events.Buildings { if b.Building == *building { if room == nil { @@ -46,5 +46,5 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin // Section implements [SectionWithTimeResolver]. func (r *sectionWithTimeResolver) Section(ctx context.Context, obj *model.SectionWithTime) (*model.Section, error) { - return r.Query().Section(ctx, obj.Section.ID) + return loaders.GetSection(ctx, obj.Section) } diff --git a/graphql/graph/generated.go b/graphql/graph/generated.go index 981090b6..70607936 100644 --- a/graphql/graph/generated.go +++ b/graphql/graph/generated.go @@ -18,6 +18,7 @@ import ( "github.com/UTDNebula/nebula-api/graphql/graph/model" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + "go.mongodb.org/mongo-driver/v2/bson" ) // region ***************************** api!.gotpl ***************************** @@ -200,12 +201,6 @@ type ComplexityRoot struct { Date func(childComplexity int) int } - Office struct { - Building func(childComplexity int) int - MapURI func(childComplexity int) int - Room func(childComplexity int) int - } - Professor struct { Email func(childComplexity int) int FirstName func(childComplexity int) int @@ -224,16 +219,16 @@ type ComplexityRoot struct { AstraEvents func(childComplexity int, date string) int AstraEventsByBuilding func(childComplexity int, date string, building string) int AstraEventsByRoom func(childComplexity int, date string, building string, room string) int - CometCalendar func(childComplexity int, id string) int + CometCalendar func(childComplexity int, id bson.ObjectID) int CometCalendars func(childComplexity int, filter *model.CometCalendarFilter, offset int32) int - Course func(childComplexity int, id string) int + Course func(childComplexity int, id bson.ObjectID) int Courses func(childComplexity int, filter *model.CourseFilter, offset int32) int Events func(childComplexity int, date string, building *string, room *string) int MazevoEvents func(childComplexity int, date string) int - Professor func(childComplexity int, id string) int + Professor func(childComplexity int, id bson.ObjectID) int Professors func(childComplexity int, filter *model.ProfessorFilter, offset int32) int Rooms func(childComplexity int) int - Section func(childComplexity int, id string) int + Section func(childComplexity int, id bson.ObjectID) int Sections func(childComplexity int, filter *model.SectionFilter, offset int32) int } @@ -288,14 +283,14 @@ type ProfessorResolver interface { } type QueryResolver interface { Courses(ctx context.Context, filter *model.CourseFilter, offset int32) ([]*model.Course, error) - Course(ctx context.Context, id string) (*model.Course, error) + Course(ctx context.Context, id bson.ObjectID) (*model.Course, error) Professors(ctx context.Context, filter *model.ProfessorFilter, offset int32) ([]*model.Professor, error) - Professor(ctx context.Context, id string) (*model.Professor, error) + Professor(ctx context.Context, id bson.ObjectID) (*model.Professor, error) Sections(ctx context.Context, filter *model.SectionFilter, offset int32) ([]*model.Section, error) - Section(ctx context.Context, id string) (*model.Section, error) + Section(ctx context.Context, id bson.ObjectID) (*model.Section, error) Rooms(ctx context.Context) ([]*model.BuildingRooms, error) CometCalendars(ctx context.Context, filter *model.CometCalendarFilter, offset int32) ([]*model.CometCalendar, error) - CometCalendar(ctx context.Context, id string) (*model.CometCalendar, error) + CometCalendar(ctx context.Context, id bson.ObjectID) (*model.CometCalendar, error) Events(ctx context.Context, date string, building *string, room *string) (model.EventResult, error) AstraEvents(ctx context.Context, date string) (*model.AstraDayEvents, error) AstraEventsByBuilding(ctx context.Context, date string, building string) (*model.AstraBuilding, error) @@ -943,25 +938,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.MultiBuildingEvents.Date(childComplexity), true - case "Office.building": - if e.ComplexityRoot.Office.Building == nil { - break - } - - return e.ComplexityRoot.Office.Building(childComplexity), true - case "Office.map_uri": - if e.ComplexityRoot.Office.MapURI == nil { - break - } - - return e.ComplexityRoot.Office.MapURI(childComplexity), true - case "Office.room": - if e.ComplexityRoot.Office.Room == nil { - break - } - - return e.ComplexityRoot.Office.Room(childComplexity), true - case "Professor.email": if e.ComplexityRoot.Professor.Email == nil { break @@ -1072,7 +1048,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.CometCalendar(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.CometCalendar(childComplexity, args["id"].(bson.ObjectID)), true case "Query.cometCalendars": if e.ComplexityRoot.Query.CometCalendars == nil { break @@ -1094,7 +1070,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Course(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Course(childComplexity, args["id"].(bson.ObjectID)), true case "Query.courses": if e.ComplexityRoot.Query.Courses == nil { break @@ -1139,7 +1115,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Professor(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Professor(childComplexity, args["id"].(bson.ObjectID)), true case "Query.professors": if e.ComplexityRoot.Query.Professors == nil { break @@ -1167,7 +1143,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Section(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Section(childComplexity, args["id"].(bson.ObjectID)), true case "Query.sections": if e.ComplexityRoot.Query.Sections == nil { break @@ -1330,15 +1306,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputCometCalendarBuildingInput, - ec.unmarshalInputCometCalendarFilter, - ec.unmarshalInputCometCalendarRoomInput, - ec.unmarshalInputCourseFilter, - ec.unmarshalInputEventInput, - ec.unmarshalInputProfessorFilter, - ec.unmarshalInputSectionFilter, - ) + inputUnmarshalers := func() *graphql.InputUnmarshalerIndex { + return graphql.NewInputUnmarshalerIndex( + graphql.NewInputUnmarshaler("CometCalendarBuildingInput", ec.unmarshalInputCometCalendarBuildingInput), + graphql.NewInputUnmarshaler("CometCalendarFilter", ec.unmarshalInputCometCalendarFilter), + graphql.NewInputUnmarshaler("CometCalendarRoomInput", ec.unmarshalInputCometCalendarRoomInput), + graphql.NewInputUnmarshaler("CourseFilter", ec.unmarshalInputCourseFilter), + graphql.NewInputUnmarshaler("EventInput", ec.unmarshalInputEventInput), + graphql.NewInputUnmarshaler("ProfessorFilter", ec.unmarshalInputProfessorFilter), + graphql.NewInputUnmarshaler("SectionFilter", ec.unmarshalInputSectionFilter), + ) + } first := true switch opCtx.Operation.Operation { @@ -1348,7 +1326,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { var data graphql.Marshaler if first { first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + ctx = graphql.WithLazyInputUnmarshalerIndex(ctx, inputUnmarshalers) data = ec._Query(ctx, opCtx.Operation.SelectionSet) } else { if atomic.LoadInt32(&ec.PendingDeferred) > 0 { @@ -1725,18 +1703,6 @@ func (ec *executionContext) childFields_Meeting(ctx context.Context, field graph return nil, fmt.Errorf("no field named %q was found under type Meeting", field.Name) } -func (ec *executionContext) childFields_Office(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "building": - return ec.fieldContext_Office_building(ctx, field) - case "map_uri": - return ec.fieldContext_Office_map_uri(ctx, field) - case "room": - return ec.fieldContext_Office_room(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Office", field.Name) -} - func (ec *executionContext) childFields_Professor(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "_id": @@ -2041,8 +2007,8 @@ func (ec *executionContext) field_Query_cometCalendar_args(ctx context.Context, var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2077,8 +2043,8 @@ func (ec *executionContext) field_Query_course_args(ctx context.Context, rawArgs var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2157,8 +2123,8 @@ func (ec *executionContext) field_Query_professor_args(ctx context.Context, rawA var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2193,8 +2159,8 @@ func (ec *executionContext) field_Query_section_args(ctx context.Context, rawArg var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2229,8 +2195,8 @@ func (ec *executionContext) field___Directive_args_args(ctx context.Context, raw var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", - func(ctx context.Context, v any) (*bool, error) { - return ec.unmarshalOBoolean2ᚖbool(ctx, v) + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) }) if err != nil { return nil, err @@ -2243,8 +2209,8 @@ func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", - func(ctx context.Context, v any) (*bool, error) { - return ec.unmarshalOBoolean2ᚖbool(ctx, v) + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) }) if err != nil { return nil, err @@ -2281,6 +2247,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field___Type_inputFields_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) + }) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + // endregion ***************************** args.gotpl ***************************** // region **************************** field.gotpl ***************************** @@ -2305,7 +2285,7 @@ func (ec *executionContext) _AcademicSession_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_AcademicSession_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "String") } func (ec *executionContext) _AcademicSession_start_date(ctx context.Context, field graphql.CollectedField, obj *model.AcademicSession) (ret graphql.Marshaler) { @@ -2328,7 +2308,7 @@ func (ec *executionContext) _AcademicSession_start_date(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_AcademicSession_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "DateTime") } func (ec *executionContext) _AcademicSession_end_date(ctx context.Context, field graphql.CollectedField, obj *model.AcademicSession) (ret graphql.Marshaler) { @@ -2351,7 +2331,7 @@ func (ec *executionContext) _AcademicSession_end_date(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AcademicSession_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "DateTime") } func (ec *executionContext) _Assistant_first_name(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2374,7 +2354,7 @@ func (ec *executionContext) _Assistant_first_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Assistant_first_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_last_name(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2397,7 +2377,7 @@ func (ec *executionContext) _Assistant_last_name(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Assistant_last_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_role(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2420,7 +2400,7 @@ func (ec *executionContext) _Assistant_role(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Assistant_role(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_email(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2443,7 +2423,7 @@ func (ec *executionContext) _Assistant_email(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_Assistant_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _AstraBuilding_building(ctx context.Context, field graphql.CollectedField, obj *model.AstraBuilding) (ret graphql.Marshaler) { @@ -2466,7 +2446,7 @@ func (ec *executionContext) _AstraBuilding_building(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_AstraBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraBuilding", field, false, false, "String") } func (ec *executionContext) _AstraBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.AstraBuilding) (ret graphql.Marshaler) { @@ -2521,7 +2501,7 @@ func (ec *executionContext) _AstraDayEvents_date(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraDayEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraDayEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraDayEvents", field, false, false, "String") } func (ec *executionContext) _AstraDayEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.AstraDayEvents) (ret graphql.Marshaler) { @@ -2576,7 +2556,7 @@ func (ec *executionContext) _AstraEvent_activity_name(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_activity_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_meeting_type(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2599,7 +2579,7 @@ func (ec *executionContext) _AstraEvent_meeting_type(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_meeting_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_start_date(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2622,7 +2602,7 @@ func (ec *executionContext) _AstraEvent_start_date(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_AstraEvent_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_end_date(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2645,7 +2625,7 @@ func (ec *executionContext) _AstraEvent_end_date(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraEvent_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_current_state(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2668,7 +2648,7 @@ func (ec *executionContext) _AstraEvent_current_state(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_current_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_not_allowed_usage_mask(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2691,7 +2671,7 @@ func (ec *executionContext) _AstraEvent_not_allowed_usage_mask(ctx context.Conte ) } func (ec *executionContext) fieldContext_AstraEvent_not_allowed_usage_mask(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "Float64") } func (ec *executionContext) _AstraEvent_usage_color(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2714,7 +2694,7 @@ func (ec *executionContext) _AstraEvent_usage_color(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_AstraEvent_usage_color(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_capacity(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2737,7 +2717,7 @@ func (ec *executionContext) _AstraEvent_capacity(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraEvent_capacity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "Float64") } func (ec *executionContext) _AstraRoom_room(ctx context.Context, field graphql.CollectedField, obj *model.AstraRoom) (ret graphql.Marshaler) { @@ -2760,7 +2740,7 @@ func (ec *executionContext) _AstraRoom_room(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_AstraRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraRoom", field, false, false, "String") } func (ec *executionContext) _AstraRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.AstraRoom) (ret graphql.Marshaler) { @@ -2815,7 +2795,7 @@ func (ec *executionContext) _BuildingRooms_building(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_BuildingRooms_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "String") } func (ec *executionContext) _BuildingRooms_rooms(ctx context.Context, field graphql.CollectedField, obj *model.BuildingRooms) (ret graphql.Marshaler) { @@ -2870,7 +2850,7 @@ func (ec *executionContext) _BuildingRooms_lat(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_BuildingRooms_lat(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "Float64") } func (ec *executionContext) _BuildingRooms_lon(ctx context.Context, field graphql.CollectedField, obj *model.BuildingRooms) (ret graphql.Marshaler) { @@ -2893,7 +2873,7 @@ func (ec *executionContext) _BuildingRooms_lon(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_BuildingRooms_lon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "Float64") } func (ec *executionContext) _CollectionRequirement_type(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2916,7 +2896,7 @@ func (ec *executionContext) _CollectionRequirement_type(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_CollectionRequirement_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "String") } func (ec *executionContext) _CollectionRequirement_name(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2939,7 +2919,7 @@ func (ec *executionContext) _CollectionRequirement_name(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_CollectionRequirement_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "String") } func (ec *executionContext) _CollectionRequirement_required(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2962,7 +2942,7 @@ func (ec *executionContext) _CollectionRequirement_required(ctx context.Context, ) } func (ec *executionContext) fieldContext_CollectionRequirement_required(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "Int") } func (ec *executionContext) _CollectionRequirement_options(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2985,7 +2965,7 @@ func (ec *executionContext) _CollectionRequirement_options(ctx context.Context, ) } func (ec *executionContext) fieldContext_CollectionRequirement_options(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "Any") } func (ec *executionContext) _CometCalendar__id(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3000,15 +2980,15 @@ func (ec *executionContext) _CometCalendar__id(ctx context.Context, field graphq return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_CometCalendar__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendar", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "ObjectID") } func (ec *executionContext) _CometCalendar_date(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3031,7 +3011,7 @@ func (ec *executionContext) _CometCalendar_date(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_CometCalendar_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendar", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "String") } func (ec *executionContext) _CometCalendar_buildings(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3086,7 +3066,7 @@ func (ec *executionContext) _CometCalendarBuilding_building(ctx context.Context, ) } func (ec *executionContext) fieldContext_CometCalendarBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendarBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendarBuilding", field, false, false, "String") } func (ec *executionContext) _CometCalendarBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendarBuilding) (ret graphql.Marshaler) { @@ -3141,7 +3121,7 @@ func (ec *executionContext) _CometCalendarRoom_room(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_CometCalendarRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendarRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendarRoom", field, false, false, "String") } func (ec *executionContext) _CometCalendarRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendarRoom) (ret graphql.Marshaler) { @@ -3188,15 +3168,15 @@ func (ec *executionContext) _Course__id(ctx context.Context, field graphql.Colle return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Course__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "ObjectID") } func (ec *executionContext) _Course_subject_prefix(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3219,7 +3199,7 @@ func (ec *executionContext) _Course_subject_prefix(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Course_subject_prefix(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_course_number(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3242,7 +3222,7 @@ func (ec *executionContext) _Course_course_number(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Course_course_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_title(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3265,7 +3245,7 @@ func (ec *executionContext) _Course_title(ctx context.Context, field graphql.Col ) } func (ec *executionContext) fieldContext_Course_title(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_description(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3288,7 +3268,7 @@ func (ec *executionContext) _Course_description(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Course_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_enrollment_reqs(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3311,7 +3291,7 @@ func (ec *executionContext) _Course_enrollment_reqs(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Course_enrollment_reqs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_school(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3334,7 +3314,7 @@ func (ec *executionContext) _Course_school(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Course_school(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_credit_hours(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3357,7 +3337,7 @@ func (ec *executionContext) _Course_credit_hours(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Course_credit_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_class_level(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3380,7 +3360,7 @@ func (ec *executionContext) _Course_class_level(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Course_class_level(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_activity_type(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3403,7 +3383,7 @@ func (ec *executionContext) _Course_activity_type(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Course_activity_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_grading(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3426,7 +3406,7 @@ func (ec *executionContext) _Course_grading(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Course_grading(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_internal_course_number(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3449,7 +3429,7 @@ func (ec *executionContext) _Course_internal_course_number(ctx context.Context, ) } func (ec *executionContext) fieldContext_Course_internal_course_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_prerequisites(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3600,7 +3580,7 @@ func (ec *executionContext) _Course_lecture_contact_hours(ctx context.Context, f ) } func (ec *executionContext) fieldContext_Course_lecture_contact_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_laboratory_contact_hours(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3623,7 +3603,7 @@ func (ec *executionContext) _Course_laboratory_contact_hours(ctx context.Context ) } func (ec *executionContext) fieldContext_Course_laboratory_contact_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_offering_frequency(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3646,7 +3626,7 @@ func (ec *executionContext) _Course_offering_frequency(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_Course_offering_frequency(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_catalog_year(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3669,7 +3649,7 @@ func (ec *executionContext) _Course_catalog_year(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Course_catalog_year(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_attributes(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3692,7 +3672,7 @@ func (ec *executionContext) _Course_attributes(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Course_attributes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "Any") } func (ec *executionContext) _Event__id(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3707,15 +3687,15 @@ func (ec *executionContext) _Event__id(ctx context.Context, field graphql.Collec return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Event__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "ObjectID") } func (ec *executionContext) _Event_summary(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3738,7 +3718,7 @@ func (ec *executionContext) _Event_summary(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Event_summary(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_location(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3761,7 +3741,7 @@ func (ec *executionContext) _Event_location(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Event_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_start_time(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3784,7 +3764,7 @@ func (ec *executionContext) _Event_start_time(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "DateTime") } func (ec *executionContext) _Event_end_time(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3807,7 +3787,7 @@ func (ec *executionContext) _Event_end_time(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Event_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "DateTime") } func (ec *executionContext) _Event_description(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3830,7 +3810,7 @@ func (ec *executionContext) _Event_description(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Event_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_type(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3853,7 +3833,7 @@ func (ec *executionContext) _Event_event_type(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_event_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_target_audience(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3876,7 +3856,7 @@ func (ec *executionContext) _Event_target_audience(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Event_target_audience(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_topic(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3899,7 +3879,7 @@ func (ec *executionContext) _Event_topic(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext_Event_topic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_tags(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3922,7 +3902,7 @@ func (ec *executionContext) _Event_event_tags(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_event_tags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_website(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3945,7 +3925,7 @@ func (ec *executionContext) _Event_event_website(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Event_event_website(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_department(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3968,7 +3948,7 @@ func (ec *executionContext) _Event_department(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_department(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_name(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3991,7 +3971,7 @@ func (ec *executionContext) _Event_contact_name(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Event_contact_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_email(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -4014,7 +3994,7 @@ func (ec *executionContext) _Event_contact_email(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Event_contact_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_phone_number(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -4037,7 +4017,7 @@ func (ec *executionContext) _Event_contact_phone_number(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_Event_contact_phone_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Location_building(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4060,7 +4040,7 @@ func (ec *executionContext) _Location_building(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Location_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _Location_room(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4083,7 +4063,7 @@ func (ec *executionContext) _Location_room(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Location_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _Location_map_uri(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4106,7 +4086,7 @@ func (ec *executionContext) _Location_map_uri(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Location_map_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _MazevoBuilding_building(ctx context.Context, field graphql.CollectedField, obj *model.MazevoBuilding) (ret graphql.Marshaler) { @@ -4129,7 +4109,7 @@ func (ec *executionContext) _MazevoBuilding_building(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoBuilding", field, false, false, "String") } func (ec *executionContext) _MazevoBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.MazevoBuilding) (ret graphql.Marshaler) { @@ -4184,7 +4164,7 @@ func (ec *executionContext) _MazevoDayEvents_date(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_MazevoDayEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoDayEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoDayEvents", field, false, false, "String") } func (ec *executionContext) _MazevoDayEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.MazevoDayEvents) (ret graphql.Marshaler) { @@ -4239,7 +4219,7 @@ func (ec *executionContext) _MazevoEvent_event_name(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_MazevoEvent_event_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_organization_name(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4262,7 +4242,7 @@ func (ec *executionContext) _MazevoEvent_organization_name(ctx context.Context, ) } func (ec *executionContext) fieldContext_MazevoEvent_organization_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_contact_name(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4285,7 +4265,7 @@ func (ec *executionContext) _MazevoEvent_contact_name(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoEvent_contact_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_setup_minutes(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4308,7 +4288,7 @@ func (ec *executionContext) _MazevoEvent_setup_minutes(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_MazevoEvent_setup_minutes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "Float64") } func (ec *executionContext) _MazevoEvent_date_time_start(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4331,7 +4311,7 @@ func (ec *executionContext) _MazevoEvent_date_time_start(ctx context.Context, fi ) } func (ec *executionContext) fieldContext_MazevoEvent_date_time_start(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_date_time_end(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4354,7 +4334,7 @@ func (ec *executionContext) _MazevoEvent_date_time_end(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_MazevoEvent_date_time_end(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_teardown_minutes(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4377,7 +4357,7 @@ func (ec *executionContext) _MazevoEvent_teardown_minutes(ctx context.Context, f ) } func (ec *executionContext) fieldContext_MazevoEvent_teardown_minutes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "Float64") } func (ec *executionContext) _MazevoEvent_status_description(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4400,7 +4380,7 @@ func (ec *executionContext) _MazevoEvent_status_description(ctx context.Context, ) } func (ec *executionContext) fieldContext_MazevoEvent_status_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_status_color(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4423,7 +4403,7 @@ func (ec *executionContext) _MazevoEvent_status_color(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoEvent_status_color(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoRoom_room(ctx context.Context, field graphql.CollectedField, obj *model.MazevoRoom) (ret graphql.Marshaler) { @@ -4446,7 +4426,7 @@ func (ec *executionContext) _MazevoRoom_room(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_MazevoRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoRoom", field, false, false, "String") } func (ec *executionContext) _MazevoRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.MazevoRoom) (ret graphql.Marshaler) { @@ -4501,7 +4481,7 @@ func (ec *executionContext) _Meeting_start_date(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Meeting_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "DateTime") } func (ec *executionContext) _Meeting_end_date(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4524,7 +4504,7 @@ func (ec *executionContext) _Meeting_end_date(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "DateTime") } func (ec *executionContext) _Meeting_meeting_days(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4547,7 +4527,7 @@ func (ec *executionContext) _Meeting_meeting_days(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Meeting_meeting_days(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_start_time(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4570,7 +4550,7 @@ func (ec *executionContext) _Meeting_start_time(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Meeting_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_end_time(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4593,7 +4573,7 @@ func (ec *executionContext) _Meeting_end_time(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_modality(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4616,7 +4596,7 @@ func (ec *executionContext) _Meeting_modality(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_modality(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_location(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4671,7 +4651,7 @@ func (ec *executionContext) _MultiBuildingEvents_date(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MultiBuildingEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MultiBuildingEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MultiBuildingEvents", field, false, false, "String") } func (ec *executionContext) _MultiBuildingEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.MultiBuildingEvents) (ret graphql.Marshaler) { @@ -4706,75 +4686,6 @@ func (ec *executionContext) fieldContext_MultiBuildingEvents_buildings(_ context return fc, nil } -func (ec *executionContext) _Office_building(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_building(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Building, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _Office_map_uri(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_map_uri(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.MapURI, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_map_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _Office_room(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_room(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Room, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) -} - func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -4787,15 +4698,15 @@ func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.Co return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Professor__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "ObjectID") } func (ec *executionContext) _Professor_first_name(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4818,7 +4729,7 @@ func (ec *executionContext) _Professor_first_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Professor_first_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_last_name(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4841,7 +4752,7 @@ func (ec *executionContext) _Professor_last_name(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Professor_last_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_titles(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4864,7 +4775,7 @@ func (ec *executionContext) _Professor_titles(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Professor_titles(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_email(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4887,7 +4798,7 @@ func (ec *executionContext) _Professor_email(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_Professor_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_phone_number(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4910,7 +4821,7 @@ func (ec *executionContext) _Professor_phone_number(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Professor_phone_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_office(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4925,8 +4836,8 @@ func (ec *executionContext) _Professor_office(ctx context.Context, field graphql return obj.Office, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v *model.Office) graphql.Marshaler { - return ec.marshalNOffice2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐOffice(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v *model.Location) graphql.Marshaler { + return ec.marshalNLocation2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐLocation(ctx, selections, v) }, true, true, @@ -4939,7 +4850,7 @@ func (ec *executionContext) fieldContext_Professor_office(_ context.Context, fie IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_Office(ctx, field) + return ec.childFields_Location(ctx, field) }, } return fc, nil @@ -4965,7 +4876,7 @@ func (ec *executionContext) _Professor_profile_uri(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Professor_profile_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_image_uri(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4988,7 +4899,7 @@ func (ec *executionContext) _Professor_image_uri(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Professor_image_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_office_hours(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -5011,7 +4922,7 @@ func (ec *executionContext) _Professor_office_hours(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Professor_office_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "Any") } func (ec *executionContext) _Professor_sections(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -5100,7 +5011,7 @@ func (ec *executionContext) _Query_course(ctx context.Context, field graphql.Col }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Course(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Course(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Course) graphql.Marshaler { @@ -5188,7 +5099,7 @@ func (ec *executionContext) _Query_professor(ctx context.Context, field graphql. }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Professor(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Professor(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Professor) graphql.Marshaler { @@ -5276,7 +5187,7 @@ func (ec *executionContext) _Query_section(ctx context.Context, field graphql.Co }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Section(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Section(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Section) graphql.Marshaler { @@ -5396,7 +5307,7 @@ func (ec *executionContext) _Query_cometCalendar(ctx context.Context, field grap }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().CometCalendar(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().CometCalendar(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.CometCalendar) graphql.Marshaler { @@ -5707,10 +5618,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }, nil, func(ctx context.Context, selections ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, selections, v) + return ec.marshalN__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, selections, v) }, true, - false, + true, ) } func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5746,7 +5657,7 @@ func (ec *executionContext) _Room_room(ctx context.Context, field graphql.Collec ) } func (ec *executionContext) fieldContext_Room_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Room", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Room", field, false, false, "String") } func (ec *executionContext) _Room_capacity(ctx context.Context, field graphql.CollectedField, obj *model.Room) (ret graphql.Marshaler) { @@ -5769,7 +5680,7 @@ func (ec *executionContext) _Room_capacity(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Room_capacity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Room", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("Room", field, false, false, "Int") } func (ec *executionContext) _RoomEvents_room(ctx context.Context, field graphql.CollectedField, obj *model.RoomEvents) (ret graphql.Marshaler) { @@ -5792,7 +5703,7 @@ func (ec *executionContext) _RoomEvents_room(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_RoomEvents_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("RoomEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("RoomEvents", field, false, false, "String") } func (ec *executionContext) _RoomEvents_section_events(ctx context.Context, field graphql.CollectedField, obj *model.RoomEvents) (ret graphql.Marshaler) { @@ -5839,15 +5750,15 @@ func (ec *executionContext) _Section__id(ctx context.Context, field graphql.Coll return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Section__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "ObjectID") } func (ec *executionContext) _Section_section_number(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -5870,7 +5781,7 @@ func (ec *executionContext) _Section_section_number(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Section_section_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_course_reference(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6053,7 +5964,7 @@ func (ec *executionContext) _Section_internal_class_number(ctx context.Context, ) } func (ec *executionContext) fieldContext_Section_internal_class_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_instruction_mode(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6076,7 +5987,7 @@ func (ec *executionContext) _Section_instruction_mode(ctx context.Context, field ) } func (ec *executionContext) fieldContext_Section_instruction_mode(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_meetings(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6131,7 +6042,7 @@ func (ec *executionContext) _Section_core_flags(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Section_core_flags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_syllabus_uri(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6154,7 +6065,7 @@ func (ec *executionContext) _Section_syllabus_uri(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Section_syllabus_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_grade_distribution(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6177,7 +6088,7 @@ func (ec *executionContext) _Section_grade_distribution(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_Section_grade_distribution(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "Int") } func (ec *executionContext) _Section_attributes(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6200,7 +6111,7 @@ func (ec *executionContext) _Section_attributes(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Section_attributes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "Any") } func (ec *executionContext) _SectionWithTime_section(ctx context.Context, field graphql.CollectedField, obj *model.SectionWithTime) (ret graphql.Marshaler) { @@ -6255,7 +6166,7 @@ func (ec *executionContext) _SectionWithTime_start_time(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_SectionWithTime_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, "String") } func (ec *executionContext) _SectionWithTime_end_time(ctx context.Context, field graphql.CollectedField, obj *model.SectionWithTime) (ret graphql.Marshaler) { @@ -6278,7 +6189,7 @@ func (ec *executionContext) _SectionWithTime_end_time(ctx context.Context, field ) } func (ec *executionContext) fieldContext_SectionWithTime_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, "String") } func (ec *executionContext) _SingleBuildingEvents_building(ctx context.Context, field graphql.CollectedField, obj *model.SingleBuildingEvents) (ret graphql.Marshaler) { @@ -6301,7 +6212,7 @@ func (ec *executionContext) _SingleBuildingEvents_building(ctx context.Context, ) } func (ec *executionContext) fieldContext_SingleBuildingEvents_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SingleBuildingEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SingleBuildingEvents", field, false, false, "String") } func (ec *executionContext) _SingleBuildingEvents_rooms(ctx context.Context, field graphql.CollectedField, obj *model.SingleBuildingEvents) (ret graphql.Marshaler) { @@ -6356,7 +6267,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "String") } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6379,7 +6290,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, true, false, "String") } func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6402,7 +6313,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field ) } func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "Boolean") } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6425,7 +6336,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type __DirectiveLocation does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "__DirectiveLocation") } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6437,7 +6348,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return ec.fieldContext___Directive_args(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.Args, nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleArgs(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -6451,7 +6363,7 @@ func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, f fc = &graphql.FieldContext{ Object: "__Directive", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return ec.childFields___InputValue(ctx, field) @@ -6491,7 +6403,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, false, false, "String") } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6514,7 +6426,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "String") } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6537,7 +6449,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ) } func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "Boolean") } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6560,7 +6472,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ) } func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "String") } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6583,7 +6495,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ) } func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, false, false, "String") } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6606,7 +6518,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "String") } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6618,7 +6530,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return ec.fieldContext___Field_args(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.Args, nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleArgs(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -6632,7 +6545,7 @@ func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field fc = &graphql.FieldContext{ Object: "__Field", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return ec.childFields___InputValue(ctx, field) @@ -6704,7 +6617,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "Boolean") } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6727,7 +6640,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "String") } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6750,7 +6663,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, false, false, "String") } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6773,7 +6686,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "String") } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6828,7 +6741,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, false, false, "String") } func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6851,7 +6764,7 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "Boolean") } func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6874,7 +6787,7 @@ func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, ) } func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "String") } func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { @@ -6897,7 +6810,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Schema", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Schema", field, true, false, "String") } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { @@ -7080,7 +6993,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type __TypeKind does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "__TypeKind") } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7103,7 +7016,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7126,7 +7039,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7149,7 +7062,7 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7313,7 +7226,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return ec.fieldContext___Type_inputFields(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.InputFields(), nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleInputFields(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -7323,7 +7237,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph false, ) } -func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -7333,6 +7247,17 @@ func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, f return ec.childFields___InputValue(ctx, field) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_inputFields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } @@ -7388,7 +7313,7 @@ func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "Boolean") } // endregion **************************** field.gotpl ***************************** @@ -7432,6 +7357,18 @@ func (ec *executionContext) unmarshalInputCometCalendarBuildingInput(ctx context return it, nil } +// UnmarshalCometCalendarBuildingInput unmarshals raw into the CometCalendarBuildingInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarBuildingInput(ctx context.Context, raw any) (model.CometCalendarBuildingInput, error) { + var out model.CometCalendarBuildingInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarBuildingInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCometCalendarFilter(ctx context.Context, obj any) (model.CometCalendarFilter, error) { var it model.CometCalendarFilter if obj == nil { @@ -7469,6 +7406,18 @@ func (ec *executionContext) unmarshalInputCometCalendarFilter(ctx context.Contex return it, nil } +// UnmarshalCometCalendarFilter unmarshals raw into the CometCalendarFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarFilter(ctx context.Context, raw any) (model.CometCalendarFilter, error) { + var out model.CometCalendarFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCometCalendarRoomInput(ctx context.Context, obj any) (model.CometCalendarRoomInput, error) { var it model.CometCalendarRoomInput if obj == nil { @@ -7506,6 +7455,18 @@ func (ec *executionContext) unmarshalInputCometCalendarRoomInput(ctx context.Con return it, nil } +// UnmarshalCometCalendarRoomInput unmarshals raw into the CometCalendarRoomInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarRoomInput(ctx context.Context, raw any) (model.CometCalendarRoomInput, error) { + var out model.CometCalendarRoomInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarRoomInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCourseFilter(ctx context.Context, obj any) (model.CourseFilter, error) { var it model.CourseFilter if obj == nil { @@ -7613,6 +7574,18 @@ func (ec *executionContext) unmarshalInputCourseFilter(ctx context.Context, obj return it, nil } +// UnmarshalCourseFilter unmarshals raw into the CourseFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCourseFilter(ctx context.Context, raw any) (model.CourseFilter, error) { + var out model.CourseFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "CourseFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputEventInput(ctx context.Context, obj any) (model.EventInput, error) { var it model.EventInput if obj == nil { @@ -7692,6 +7665,18 @@ func (ec *executionContext) unmarshalInputEventInput(ctx context.Context, obj an return it, nil } +// UnmarshalEventInput unmarshals raw into the EventInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalEventInput(ctx context.Context, raw any) (model.EventInput, error) { + var out model.EventInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "EventInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputProfessorFilter(ctx context.Context, obj any) (model.ProfessorFilter, error) { var it model.ProfessorFilter if obj == nil { @@ -7750,6 +7735,18 @@ func (ec *executionContext) unmarshalInputProfessorFilter(ctx context.Context, o return it, nil } +// UnmarshalProfessorFilter unmarshals raw into the ProfessorFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalProfessorFilter(ctx context.Context, raw any) (model.ProfessorFilter, error) { + var out model.ProfessorFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "ProfessorFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj any) (model.SectionFilter, error) { var it model.SectionFilter if obj == nil { @@ -7777,7 +7774,7 @@ func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj it.SectionNumber = data case "course_reference": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("course_reference")) - data, err := ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) if err != nil { return it, err } @@ -7808,6 +7805,18 @@ func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj return it, nil } +// UnmarshalSectionFilter unmarshals raw into the SectionFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalSectionFilter(ctx context.Context, raw any) (model.SectionFilter, error) { + var out model.SectionFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "SectionFilter", raw, &out) + return out, err +} + // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -7863,8 +7872,7 @@ func (ec *executionContext) _AcademicSession(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, academicSessionImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7893,14 +7901,10 @@ func (ec *executionContext) _AcademicSession(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -7911,8 +7915,7 @@ func (ec *executionContext) _Assistant(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, assistantImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7946,14 +7949,10 @@ func (ec *executionContext) _Assistant(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -7964,8 +7963,7 @@ func (ec *executionContext) _AstraBuilding(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, astraBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7989,14 +7987,10 @@ func (ec *executionContext) _AstraBuilding(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8007,8 +8001,7 @@ func (ec *executionContext) _AstraDayEvents(ctx context.Context, sel ast.Selecti fields := graphql.CollectFields(ec.OperationContext, sel, astraDayEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8032,14 +8025,10 @@ func (ec *executionContext) _AstraDayEvents(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8050,8 +8039,7 @@ func (ec *executionContext) _AstraEvent(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, astraEventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8105,14 +8093,10 @@ func (ec *executionContext) _AstraEvent(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8123,8 +8107,7 @@ func (ec *executionContext) _AstraRoom(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, astraRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8148,14 +8131,10 @@ func (ec *executionContext) _AstraRoom(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8166,8 +8145,7 @@ func (ec *executionContext) _BuildingRooms(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, buildingRoomsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8201,14 +8179,10 @@ func (ec *executionContext) _BuildingRooms(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8219,8 +8193,7 @@ func (ec *executionContext) _CollectionRequirement(ctx context.Context, sel ast. fields := graphql.CollectFields(ec.OperationContext, sel, collectionRequirementImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8254,14 +8227,10 @@ func (ec *executionContext) _CollectionRequirement(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8272,8 +8241,7 @@ func (ec *executionContext) _CometCalendar(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8302,14 +8270,10 @@ func (ec *executionContext) _CometCalendar(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8320,8 +8284,7 @@ func (ec *executionContext) _CometCalendarBuilding(ctx context.Context, sel ast. fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8345,14 +8308,10 @@ func (ec *executionContext) _CometCalendarBuilding(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8363,8 +8322,7 @@ func (ec *executionContext) _CometCalendarRoom(ctx context.Context, sel ast.Sele fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8388,14 +8346,10 @@ func (ec *executionContext) _CometCalendarRoom(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8406,8 +8360,7 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o fields := graphql.CollectFields(ec.OperationContext, sel, courseImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8488,43 +8441,11 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o atomic.AddUint32(&out.Invalids, 1) } case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Course_sections(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Course_sections(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "lecture_contact_hours": out.Values[i] = ec._Course_lecture_contact_hours(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -8559,14 +8480,10 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8577,8 +8494,7 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob fields := graphql.CollectFields(ec.OperationContext, sel, eventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8667,14 +8583,10 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8685,8 +8597,7 @@ func (ec *executionContext) _Location(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, locationImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8715,14 +8626,10 @@ func (ec *executionContext) _Location(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8733,8 +8640,7 @@ func (ec *executionContext) _MazevoBuilding(ctx context.Context, sel ast.Selecti fields := graphql.CollectFields(ec.OperationContext, sel, mazevoBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8758,14 +8664,10 @@ func (ec *executionContext) _MazevoBuilding(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8776,8 +8678,7 @@ func (ec *executionContext) _MazevoDayEvents(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, mazevoDayEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8801,14 +8702,10 @@ func (ec *executionContext) _MazevoDayEvents(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8819,8 +8716,7 @@ func (ec *executionContext) _MazevoEvent(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, mazevoEventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8879,14 +8775,10 @@ func (ec *executionContext) _MazevoEvent(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8897,8 +8789,7 @@ func (ec *executionContext) _MazevoRoom(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, mazevoRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8922,14 +8813,10 @@ func (ec *executionContext) _MazevoRoom(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8940,8 +8827,7 @@ func (ec *executionContext) _Meeting(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, meetingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8990,14 +8876,10 @@ func (ec *executionContext) _Meeting(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9008,8 +8890,7 @@ func (ec *executionContext) _MultiBuildingEvents(ctx context.Context, sel ast.Se fields := graphql.CollectFields(ec.OperationContext, sel, multiBuildingEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9033,63 +8914,11 @@ func (ec *executionContext) _MultiBuildingEvents(ctx context.Context, sel ast.Se return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var officeImplementors = []string{"Office"} - -func (ec *executionContext) _Office(ctx context.Context, sel ast.SelectionSet, obj *model.Office) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, officeImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Office") - case "building": - out.Values[i] = ec._Office_building(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "map_uri": - out.Values[i] = ec._Office_map_uri(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "room": - out.Values[i] = ec._Office_room(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - return out } @@ -9099,8 +8928,7 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, professorImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9156,43 +8984,11 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet atomic.AddUint32(&out.Invalids, 1) } case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Professor_sections(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Professor_sections(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9202,14 +8998,10 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9223,8 +9015,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -9235,313 +9026,89 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "courses": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_courses(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_courses(ctx, field) + }) case "course": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_course(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_course(ctx, field) + }) case "professors": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_professors(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_professors(ctx, field) + }) case "professor": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_professor(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_professor(ctx, field) + }) case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_sections(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_sections(ctx, field) + }) case "section": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_section(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_section(ctx, field) + }) case "rooms": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_rooms(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_rooms(ctx, field) + }) case "cometCalendars": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_cometCalendars(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_cometCalendars(ctx, field) + }) case "cometCalendar": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_cometCalendar(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_cometCalendar(ctx, field) + }) case "events": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_events(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_events(ctx, field) + }) case "astraEvents": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEvents(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEvents(ctx, field) + }) case "astraEventsByBuilding": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEventsByBuilding(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEventsByBuilding(ctx, field) + }) case "astraEventsByRoom": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEventsByRoom(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEventsByRoom(ctx, field) + }) case "mazevoEvents": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_mazevoEvents(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_mazevoEvents(ctx, field) + }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) @@ -9553,7 +9120,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - if out.Values[i] == graphql.RequiredNull { + if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: @@ -9565,14 +9132,10 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9583,8 +9146,7 @@ func (ec *executionContext) _Room(ctx context.Context, sel ast.SelectionSet, obj fields := graphql.CollectFields(ec.OperationContext, sel, roomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9608,14 +9170,10 @@ func (ec *executionContext) _Room(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9626,8 +9184,7 @@ func (ec *executionContext) _RoomEvents(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, roomEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9651,14 +9208,10 @@ func (ec *executionContext) _RoomEvents(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9669,8 +9222,7 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, sectionImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9686,43 +9238,11 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, atomic.AddUint32(&out.Invalids, 1) } case "course_reference": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Section_course_reference(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Section_course_reference(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "section_corequisites": out.Values[i] = ec._Section_section_corequisites(ctx, field, obj) if out.Values[i] == graphql.RequiredNull { @@ -9734,43 +9254,11 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, atomic.AddUint32(&out.Invalids, 1) } case "professors": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Section_professors(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Section_professors(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "teaching_assistants": out.Values[i] = ec._Section_teaching_assistants(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -9820,14 +9308,10 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9838,50 +9322,17 @@ func (ec *executionContext) _SectionWithTime(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, sectionWithTimeImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("SectionWithTime") case "section": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._SectionWithTime_section(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._SectionWithTime_section(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "start_time": out.Values[i] = ec._SectionWithTime_start_time(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -9901,14 +9352,10 @@ func (ec *executionContext) _SectionWithTime(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9919,8 +9366,7 @@ func (ec *executionContext) _SingleBuildingEvents(ctx context.Context, sel ast.S fields := graphql.CollectFields(ec.OperationContext, sel, singleBuildingEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9944,14 +9390,10 @@ func (ec *executionContext) _SingleBuildingEvents(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9962,8 +9404,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10002,14 +9443,10 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10020,8 +9457,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10055,14 +9491,10 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10073,8 +9505,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10118,14 +9549,10 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10136,8 +9563,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10181,14 +9607,10 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10199,8 +9621,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10244,14 +9665,10 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10262,8 +9679,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10332,14 +9748,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10350,9 +9762,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o func (ec *executionContext) marshalNAcademicSession2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAcademicSession(ctx context.Context, sel ast.SelectionSet, v *model.AcademicSession) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AcademicSession!") return graphql.Null } return ec._AcademicSession(ctx, sel, v) @@ -10376,9 +9786,7 @@ func (ec *executionContext) marshalNAssistant2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNAssistant2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAssistant(ctx context.Context, sel ast.SelectionSet, v *model.Assistant) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Assistant!") return graphql.Null } return ec._Assistant(ctx, sel, v) @@ -10402,9 +9810,7 @@ func (ec *executionContext) marshalNAstraBuilding2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNAstraBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraBuilding(ctx context.Context, sel ast.SelectionSet, v *model.AstraBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraBuilding!") return graphql.Null } return ec._AstraBuilding(ctx, sel, v) @@ -10428,9 +9834,7 @@ func (ec *executionContext) marshalNAstraEvent2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNAstraEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraEvent(ctx context.Context, sel ast.SelectionSet, v *model.AstraEvent) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraEvent!") return graphql.Null } return ec._AstraEvent(ctx, sel, v) @@ -10454,9 +9858,7 @@ func (ec *executionContext) marshalNAstraRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNAstraRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraRoom(ctx context.Context, sel ast.SelectionSet, v *model.AstraRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraRoom!") return graphql.Null } return ec._AstraRoom(ctx, sel, v) @@ -10471,9 +9873,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se _ = sel res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Boolean!") } return res } @@ -10496,9 +9896,7 @@ func (ec *executionContext) marshalNBuildingRooms2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNBuildingRooms2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐBuildingRooms(ctx context.Context, sel ast.SelectionSet, v *model.BuildingRooms) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "BuildingRooms!") return graphql.Null } return ec._BuildingRooms(ctx, sel, v) @@ -10522,9 +9920,7 @@ func (ec *executionContext) marshalNCometCalendar2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNCometCalendar2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendar(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendar) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendar!") return graphql.Null } return ec._CometCalendar(ctx, sel, v) @@ -10548,9 +9944,7 @@ func (ec *executionContext) marshalNCometCalendarBuilding2ᚕᚖgithubᚗcomᚋU func (ec *executionContext) marshalNCometCalendarBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendarBuilding(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendarBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendarBuilding!") return graphql.Null } return ec._CometCalendarBuilding(ctx, sel, v) @@ -10574,9 +9968,7 @@ func (ec *executionContext) marshalNCometCalendarRoom2ᚕᚖgithubᚗcomᚋUTDNe func (ec *executionContext) marshalNCometCalendarRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendarRoom(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendarRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendarRoom!") return graphql.Null } return ec._CometCalendarRoom(ctx, sel, v) @@ -10600,9 +9992,7 @@ func (ec *executionContext) marshalNCourse2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebu func (ec *executionContext) marshalNCourse2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCourse(ctx context.Context, sel ast.SelectionSet, v *model.Course) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Course!") return graphql.Null } return ec._Course(ctx, sel, v) @@ -10617,9 +10007,7 @@ func (ec *executionContext) marshalNDateTime2timeᚐTime(ctx context.Context, se _ = sel res := graphql.MarshalTime(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "DateTime!") } return res } @@ -10642,9 +10030,7 @@ func (ec *executionContext) marshalNEvent2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebul func (ec *executionContext) marshalNEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐEvent(ctx context.Context, sel ast.SelectionSet, v *model.Event) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Event!") return graphql.Null } return ec._Event(ctx, sel, v) @@ -10659,25 +10045,7 @@ func (ec *executionContext) marshalNFloat642float64(ctx context.Context, sel ast _ = sel res := graphql.MarshalFloat(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := graphql.MarshalID(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Float64!") } return res } @@ -10691,18 +10059,14 @@ func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.Selec _ = sel res := graphql.MarshalInt32(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Int!") } return res } func (ec *executionContext) marshalNLocation2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐLocation(ctx context.Context, sel ast.SelectionSet, v *model.Location) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Location!") return graphql.Null } return ec._Location(ctx, sel, v) @@ -10726,9 +10090,7 @@ func (ec *executionContext) marshalNMazevoBuilding2ᚕᚖgithubᚗcomᚋUTDNebul func (ec *executionContext) marshalNMazevoBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoBuilding(ctx context.Context, sel ast.SelectionSet, v *model.MazevoBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoBuilding!") return graphql.Null } return ec._MazevoBuilding(ctx, sel, v) @@ -10752,9 +10114,7 @@ func (ec *executionContext) marshalNMazevoEvent2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNMazevoEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoEvent(ctx context.Context, sel ast.SelectionSet, v *model.MazevoEvent) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoEvent!") return graphql.Null } return ec._MazevoEvent(ctx, sel, v) @@ -10778,9 +10138,7 @@ func (ec *executionContext) marshalNMazevoRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNMazevoRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoRoom(ctx context.Context, sel ast.SelectionSet, v *model.MazevoRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoRoom!") return graphql.Null } return ec._MazevoRoom(ctx, sel, v) @@ -10804,22 +10162,24 @@ func (ec *executionContext) marshalNMeeting2ᚕᚖgithubᚗcomᚋUTDNebulaᚋneb func (ec *executionContext) marshalNMeeting2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMeeting(ctx context.Context, sel ast.SelectionSet, v *model.Meeting) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Meeting!") return graphql.Null } return ec._Meeting(ctx, sel, v) } -func (ec *executionContext) marshalNOffice2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐOffice(ctx context.Context, sel ast.SelectionSet, v *model.Office) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null +func (ec *executionContext) unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, v any) (bson.ObjectID, error) { + res, err := model.UnmarshalObjectID(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, sel ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + _ = sel + res := model.MarshalObjectID(v) + if res == graphql.Null { + graphql.AddInvalidNullFromMarshaler(ctx, "ObjectID!") } - return ec._Office(ctx, sel, v) + return res } func (ec *executionContext) marshalNProfessor2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessorᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Professor) graphql.Marshaler { @@ -10840,9 +10200,7 @@ func (ec *executionContext) marshalNProfessor2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNProfessor2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessor(ctx context.Context, sel ast.SelectionSet, v *model.Professor) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Professor!") return graphql.Null } return ec._Professor(ctx, sel, v) @@ -10866,9 +10224,7 @@ func (ec *executionContext) marshalNRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebula func (ec *executionContext) marshalNRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐRoom(ctx context.Context, sel ast.SelectionSet, v *model.Room) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Room!") return graphql.Null } return ec._Room(ctx, sel, v) @@ -10892,9 +10248,7 @@ func (ec *executionContext) marshalNRoomEvents2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNRoomEvents2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐRoomEvents(ctx context.Context, sel ast.SelectionSet, v *model.RoomEvents) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "RoomEvents!") return graphql.Null } return ec._RoomEvents(ctx, sel, v) @@ -10918,9 +10272,7 @@ func (ec *executionContext) marshalNSection2ᚕᚖgithubᚗcomᚋUTDNebulaᚋneb func (ec *executionContext) marshalNSection2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSection(ctx context.Context, sel ast.SelectionSet, v *model.Section) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Section!") return graphql.Null } return ec._Section(ctx, sel, v) @@ -10944,9 +10296,7 @@ func (ec *executionContext) marshalNSectionWithTime2ᚕᚖgithubᚗcomᚋUTDNebu func (ec *executionContext) marshalNSectionWithTime2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSectionWithTime(ctx context.Context, sel ast.SelectionSet, v *model.SectionWithTime) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "SectionWithTime!") return graphql.Null } return ec._SectionWithTime(ctx, sel, v) @@ -10970,9 +10320,7 @@ func (ec *executionContext) marshalNSingleBuildingEvents2ᚕᚖgithubᚗcomᚋUT func (ec *executionContext) marshalNSingleBuildingEvents2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSingleBuildingEvents(ctx context.Context, sel ast.SelectionSet, v *model.SingleBuildingEvents) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "SingleBuildingEvents!") return graphql.Null } return ec._SingleBuildingEvents(ctx, sel, v) @@ -10987,9 +10335,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "String!") } return res } @@ -11052,9 +10398,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "__DirectiveLocation!") } return res } @@ -11117,6 +10461,14 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } +func (ec *executionContext) marshalN__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + graphql.AddInvalidNullError(ctx, "__Schema!") + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { return ec.___Type(ctx, sel, &v) } @@ -11139,9 +10491,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "__Type!") return graphql.Null } return ec.___Type(ctx, sel, v) @@ -11156,9 +10506,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "__TypeKind!") } return res } @@ -11387,24 +10735,6 @@ func (ec *executionContext) marshalOFloat642ᚖfloat64(ctx context.Context, sel return res } -func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v any) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - _ = sel - _ = ctx - res := graphql.MarshalID(*v) - return res -} - func (ec *executionContext) unmarshalOInt2ᚕint32ᚄ(ctx context.Context, v any) ([]int32, error) { if v == nil { return nil, nil @@ -11447,6 +10777,24 @@ func (ec *executionContext) marshalOMazevoDayEvents2ᚖgithubᚗcomᚋUTDNebula return ec._MazevoDayEvents(ctx, sel, v) } +func (ec *executionContext) unmarshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, v any) (*bson.ObjectID, error) { + if v == nil { + return nil, nil + } + res, err := model.UnmarshalObjectID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, sel ast.SelectionSet, v *bson.ObjectID) graphql.Marshaler { + if v == nil { + return graphql.Null + } + _ = sel + _ = ctx + res := model.MarshalObjectID(*v) + return res +} + func (ec *executionContext) marshalOProfessor2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessor(ctx context.Context, sel ast.SelectionSet, v *model.Professor) graphql.Marshaler { if v == nil { return graphql.Null @@ -11581,13 +10929,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/graphql/graph/model/db_models.go b/graphql/graph/model/db_models.go deleted file mode 100644 index 6fbc8eb1..00000000 --- a/graphql/graph/model/db_models.go +++ /dev/null @@ -1,374 +0,0 @@ -package model - -import ( - "time" - - "go.mongodb.org/mongo-driver/v2/bson" -) - -/* -These are the models that interact with the MongoDB -*/ - -type DBCollectionRequirement struct { - Type string `bson:"type"` - Name string `bson:"name"` - Required int32 `bson:"required"` - Options any `bson:"options"` -} - -func transformColReq(dbColReq *DBCollectionRequirement) *CollectionRequirement { - if dbColReq == nil { - return nil - } - return &CollectionRequirement{ - dbColReq.Type, - dbColReq.Name, - dbColReq.Required, - dbColReq.Options, - } -} - -// NOTE: For now, course on Mongo side is identical to course on GraphQL side -// However, in the near future, when we implement the REFERENCE RESOLVER, there will be diffs -type DBCourse struct { - ID bson.ObjectID `bson:"_id"` - SubjectPrefix string `bson:"subject_prefix"` - CourseNumber string `bson:"course_number"` - Title string `bson:"title"` - Description string `bson:"description"` - EnrollmentReqs string `bson:"enrollment_reqs"` - School string `bson:"school"` - CreditHours string `bson:"credit_hours"` - ClassLevel string `bson:"class_level"` - ActivityType string `bson:"activity_type"` - Grading string `bson:"grading"` - InternalCourseNumber string `bson:"internal_course_number"` - Prerequisites *DBCollectionRequirement `bson:"prerequisites"` - Corequisites *DBCollectionRequirement `bson:"corequisites"` - CoOrPreRequisites *DBCollectionRequirement `bson:"co_or_pre_requisites"` - Sections []bson.ObjectID `bson:"sections"` - LectureContactHours string `bson:"lecture_contact_hours"` - LaboratoryContactHours string `bson:"laboratory_contact_hours"` - OfferingFrequency string `bson:"offering_frequency"` - CatalogYear string `bson:"catalog_year"` - Attributes any `bson:"attributes"` -} - -// Transform the course object that interacts with Mongo to the course object that interacts with GraphQL -func TransformCourse(dbCourse *DBCourse) *Course { - if dbCourse == nil { - return nil - } - - sections := make([]*Section, len(dbCourse.Sections)) - for i, sectionID := range dbCourse.Sections { - sections[i] = &Section{ID: sectionID.Hex()} - } - - return &Course{ - dbCourse.ID.Hex(), - dbCourse.SubjectPrefix, - dbCourse.CourseNumber, - dbCourse.Title, - dbCourse.Description, - dbCourse.EnrollmentReqs, - dbCourse.School, - dbCourse.CreditHours, - dbCourse.ClassLevel, - dbCourse.ActivityType, - dbCourse.Grading, - dbCourse.InternalCourseNumber, - transformColReq(dbCourse.Prerequisites), - transformColReq(dbCourse.Corequisites), - transformColReq(dbCourse.Corequisites), - sections, - dbCourse.LectureContactHours, - dbCourse.LaboratoryContactHours, - dbCourse.OfferingFrequency, - dbCourse.CatalogYear, - dbCourse.Attributes, - } -} - -type DBOffice struct { - Building string `bson:"building"` - MapURI string `bson:"map_uri"` - Room string `bson:"room"` -} - -func TransformOffice(dbOffice *DBOffice) *Office { - if dbOffice == nil { - return nil - } - return &Office{ - dbOffice.Building, - dbOffice.MapURI, - dbOffice.Room, - } -} - -type DBProfessor struct { - ID bson.ObjectID `bson:"_id"` - FirstName string `bson:"first_name"` - LastName string `bson:"last_name"` - Titles []string `bson:"titles"` - Email string `bson:"email"` - PhoneNumber string `bson:"phone_number"` - Office *DBOffice `bson:"office"` - ProfileURI string `bson:"profile_uri"` - ImageURI string `bson:"image_uri"` - OfficeHours any `bson:"office_hours"` - Sections []bson.ObjectID `bson:"sections"` -} - -func TransformProfessor(dbProfessor *DBProfessor) *Professor { - if dbProfessor == nil { - return nil - } - - sections := make([]*Section, len(dbProfessor.Sections)) - for i, sectionID := range dbProfessor.Sections { - sections[i] = &Section{ID: sectionID.Hex()} - } - - return &Professor{ - dbProfessor.ID.Hex(), - dbProfessor.FirstName, - dbProfessor.LastName, - dbProfessor.Titles, - dbProfessor.Email, - dbProfessor.PhoneNumber, - TransformOffice(dbProfessor.Office), - dbProfessor.ProfileURI, - dbProfessor.ImageURI, - dbProfessor.OfficeHours, - sections, - } -} - -// --- Section DB Models and Transformers --- -type DBAcademicSession struct { - Name string `bson:"name"` - StartDate time.Time `bson:"start_date"` - EndDate time.Time `bson:"end_date"` -} - -type DBAssistant struct { - FirstName string `bson:"first_name"` - LastName string `bson:"last_name"` - Role string `bson:"role"` - Email string `bson:"email"` -} - -type DBLocation struct { - Building string `bson:"building"` - Room string `bson:"room"` - MapURI string `bson:"map_uri"` -} - -type DBMeeting struct { - StartDate time.Time `bson:"start_date"` - EndDate time.Time `bson:"end_date"` - MeetingDays []string `bson:"meeting_days"` - StartTime string `bson:"start_time"` - EndTime string `bson:"end_time"` - Modality string `bson:"modality"` - Location DBLocation `bson:"location"` -} - -type DBSection struct { - ID bson.ObjectID `bson:"_id"` - SectionNumber string `bson:"section_number"` - CourseReference bson.ObjectID `bson:"course_reference"` - SectionCorequisites *DBCollectionRequirement `bson:"section_corequisites"` - AcademicSession DBAcademicSession `bson:"academic_session"` - Professors []bson.ObjectID `bson:"professors"` - TeachingAssistants []DBAssistant `bson:"teaching_assistants"` - InternalClassNumber string `bson:"internal_class_number"` - InstructionMode string `bson:"instruction_mode"` - Meetings []DBMeeting `bson:"meetings"` - CoreFlags []string `bson:"core_flags"` - SyllabusURI string `bson:"syllabus_uri"` - GradeDistribution []int32 `bson:"grade_distribution"` - Attributes any `bson:"attributes"` -} - -func transformAcademicSession(dbSession *DBAcademicSession) *AcademicSession { - if dbSession == nil { - return nil - } - return &AcademicSession{ - Name: dbSession.Name, - StartDate: dbSession.StartDate, - EndDate: dbSession.EndDate, - } -} - -func transformAssistant(dbAssistant *DBAssistant) *Assistant { - if dbAssistant == nil { - return nil - } - return &Assistant{ - FirstName: dbAssistant.FirstName, - LastName: dbAssistant.LastName, - Role: dbAssistant.Role, - Email: dbAssistant.Email, - } -} - -func transformLocation(dbLocation *DBLocation) *Location { - if dbLocation == nil { - return nil - } - return &Location{ - Building: dbLocation.Building, - Room: dbLocation.Room, - MapURI: dbLocation.MapURI, - } -} - -func transformMeeting(dbMeeting *DBMeeting) *Meeting { - if dbMeeting == nil { - return nil - } - return &Meeting{ - StartDate: dbMeeting.StartDate, - EndDate: dbMeeting.EndDate, - MeetingDays: dbMeeting.MeetingDays, - StartTime: dbMeeting.StartTime, - EndTime: dbMeeting.EndTime, - Modality: dbMeeting.Modality, - Location: transformLocation(&dbMeeting.Location), - } -} - -// TransformSection converts a database section model into a GraphQL Section type. -func TransformSection(dbSection *DBSection) *Section { - if dbSection == nil { - return nil - } - - courseRef := &Course{ - ID: dbSection.CourseReference.Hex(), - } - - professors := make([]*Professor, len(dbSection.Professors)) - for i, professorID := range dbSection.Professors { - professors[i] = &Professor{ - ID: professorID.Hex(), - } - } - - assistants := make([]*Assistant, len(dbSection.TeachingAssistants)) - for i := range dbSection.TeachingAssistants { - assistants[i] = transformAssistant(&dbSection.TeachingAssistants[i]) - } - - meetings := make([]*Meeting, len(dbSection.Meetings)) - for i := range dbSection.Meetings { - meetings[i] = transformMeeting(&dbSection.Meetings[i]) - } - - return &Section{ - ID: dbSection.ID.Hex(), - SectionNumber: dbSection.SectionNumber, - CourseReference: courseRef, - SectionCorequisites: transformColReq(dbSection.SectionCorequisites), - AcademicSession: transformAcademicSession(&dbSection.AcademicSession), - Professors: professors, - TeachingAssistants: assistants, - InternalClassNumber: dbSection.InternalClassNumber, - InstructionMode: dbSection.InstructionMode, - Meetings: meetings, - CoreFlags: dbSection.CoreFlags, - SyllabusURI: dbSection.SyllabusURI, - GradeDistribution: dbSection.GradeDistribution, - Attributes: dbSection.Attributes, - } -} - -// Event DB Models since it references Section -type DBMultiBuildingEvents struct { - Date string `bson:"date" json:"date"` - Buildings []DBSingleBuildingEvents `bson:"buildings" json:"buildings"` -} - -type DBSingleBuildingEvents struct { - Building string `bson:"building" json:"building"` - Rooms []DBRoomEvents `bson:"rooms" json:"rooms"` -} - -type DBRoomEvents struct { - Room string `bson:"room" json:"room"` - Events []DBSectionWithTime `bson:"events" json:"events"` -} - -type DBSectionWithTime struct { - Section bson.ObjectID `bson:"section" json:"section"` - StartTime string `bson:"start_time" json:"start_time"` - EndTime string `bson:"end_time" json:"end_time"` -} - -func TransformSectionWithTime(dbSectionWithTime *DBSectionWithTime) *SectionWithTime { - if dbSectionWithTime == nil { - return nil - } - sectionWithID := Section{ - ID: dbSectionWithTime.Section.Hex(), - } - - return &SectionWithTime{ - Section: §ionWithID, - StartTime: dbSectionWithTime.StartTime, - EndTime: dbSectionWithTime.EndTime, - } -} - -func TransformRoomEvents(dbRoomEvents *DBRoomEvents) *RoomEvents { - if dbRoomEvents == nil { - return nil - } - - events := make([]*SectionWithTime, len(dbRoomEvents.Events)) - for i := range dbRoomEvents.Events { - events[i] = TransformSectionWithTime(&dbRoomEvents.Events[i]) - } - - return &RoomEvents{ - Room: dbRoomEvents.Room, - SectionEvents: events, - } -} - -func TransformSingleBuildingEvents(dbSingleBuildingEvents *DBSingleBuildingEvents) *SingleBuildingEvents { - if dbSingleBuildingEvents == nil { - return nil - } - - rooms := make([]*RoomEvents, len(dbSingleBuildingEvents.Rooms)) - for i := range dbSingleBuildingEvents.Rooms { - rooms[i] = TransformRoomEvents(&dbSingleBuildingEvents.Rooms[i]) - } - - return &SingleBuildingEvents{ - Building: dbSingleBuildingEvents.Building, - Rooms: rooms, - } -} - -func TransformMultiBuildingEvents(dbMultiBuildingEvents *DBMultiBuildingEvents) *MultiBuildingEvents { - if dbMultiBuildingEvents == nil { - return nil - } - - buildings := make([]*SingleBuildingEvents, len(dbMultiBuildingEvents.Buildings)) - for i := range dbMultiBuildingEvents.Buildings { - buildings[i] = TransformSingleBuildingEvents(&dbMultiBuildingEvents.Buildings[i]) - } - - return &MultiBuildingEvents{ - Date: dbMultiBuildingEvents.Date, - Buildings: buildings, - } -} diff --git a/graphql/graph/model/db_models_test.go b/graphql/graph/model/db_models_test.go deleted file mode 100644 index 6c96193a..00000000 --- a/graphql/graph/model/db_models_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package model - -import ( - "testing" - "time" - - "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/v2/bson" -) - -func TestTransformProfessor(t *testing.T) { - input := &DBProfessor{ - ID: bson.ObjectID{1}, - FirstName: "Ada", - LastName: "Example", - Titles: []string{"Professor", "Department Chair"}, - Email: "ada@example.com", - PhoneNumber: "555-0100", - Office: &DBOffice{Building: "ECSS", MapURI: "https://example.com/office", Room: "3.100"}, - ProfileURI: "https://example.com/profile", - ImageURI: "https://example.com/image", - OfficeHours: []string{"Monday 10:00-11:00"}, - Sections: []bson.ObjectID{{2}, {3}}, - } - want := &Professor{ - ID: "010000000000000000000000", - FirstName: "Ada", - LastName: "Example", - Titles: []string{"Professor", "Department Chair"}, - Email: "ada@example.com", - PhoneNumber: "555-0100", - Office: &Office{Building: "ECSS", MapURI: "https://example.com/office", Room: "3.100"}, - ProfileURI: "https://example.com/profile", - ImageURI: "https://example.com/image", - OfficeHours: []string{"Monday 10:00-11:00"}, - Sections: []*Section{ - {ID: "020000000000000000000000"}, - {ID: "030000000000000000000000"}, - }, - } - - if diff := cmp.Diff(want, TransformProfessor(input)); diff != "" { - t.Fatalf("TransformProfessor() mismatch (-want +got):\n%s", diff) - } -} - -func TestTransformProfessorNil(t *testing.T) { - if got := TransformProfessor(nil); got != nil { - t.Fatalf("TransformProfessor(nil) = %v, want nil", got) - } -} - -func TestTransformSection(t *testing.T) { - startDate := time.Date(2026, time.August, 17, 0, 0, 0, 0, time.UTC) - endDate := time.Date(2026, time.December, 11, 0, 0, 0, 0, time.UTC) - input := &DBSection{ - ID: bson.ObjectID{2}, - SectionNumber: "001", - CourseReference: bson.ObjectID{4}, - SectionCorequisites: &DBCollectionRequirement{ - Type: "all", Name: "Lab", Required: 1, Options: []string{"CS 1100"}, - }, - AcademicSession: DBAcademicSession{Name: "Fall 2026", StartDate: startDate, EndDate: endDate}, - Professors: []bson.ObjectID{{1}, {3}}, - TeachingAssistants: []DBAssistant{ - {FirstName: "Grace", LastName: "Example", Role: "TA", Email: "grace@example.com"}, - {FirstName: "Alan", LastName: "Sample", Role: "Tutor", Email: "alan@example.com"}, - }, - InternalClassNumber: "12345", - InstructionMode: "In Person", - Meetings: []DBMeeting{ - { - StartDate: startDate, EndDate: endDate, - MeetingDays: []string{"Monday", "Wednesday"}, StartTime: "10:00", EndTime: "11:15", - Modality: "Lecture", Location: DBLocation{Building: "ECSS", Room: "2.100", MapURI: "https://example.com/lecture"}, - }, - { - StartDate: startDate.AddDate(0, 0, 1), EndDate: endDate.AddDate(0, 0, -1), - MeetingDays: []string{"Tuesday"}, StartTime: "14:00", EndTime: "15:00", - Modality: "Lab", Location: DBLocation{Building: "ECSW", Room: "1.200", MapURI: "https://example.com/lab"}, - }, - }, - CoreFlags: []string{"030", "090"}, - SyllabusURI: "https://example.com/syllabus", - GradeDistribution: []int32{10, 8, 3, 1, 0}, - Attributes: map[string]string{"topic": "Computing"}, - } - want := &Section{ - ID: "020000000000000000000000", - SectionNumber: "001", - CourseReference: &Course{ID: "040000000000000000000000"}, - SectionCorequisites: &CollectionRequirement{ - Type: "all", Name: "Lab", Required: 1, Options: []string{"CS 1100"}, - }, - AcademicSession: &AcademicSession{Name: "Fall 2026", StartDate: startDate, EndDate: endDate}, - Professors: []*Professor{ - {ID: "010000000000000000000000"}, - {ID: "030000000000000000000000"}, - }, - TeachingAssistants: []*Assistant{ - {FirstName: "Grace", LastName: "Example", Role: "TA", Email: "grace@example.com"}, - {FirstName: "Alan", LastName: "Sample", Role: "Tutor", Email: "alan@example.com"}, - }, - InternalClassNumber: "12345", - InstructionMode: "In Person", - Meetings: []*Meeting{ - { - StartDate: startDate, EndDate: endDate, - MeetingDays: []string{"Monday", "Wednesday"}, StartTime: "10:00", EndTime: "11:15", - Modality: "Lecture", Location: &Location{Building: "ECSS", Room: "2.100", MapURI: "https://example.com/lecture"}, - }, - { - StartDate: startDate.AddDate(0, 0, 1), EndDate: endDate.AddDate(0, 0, -1), - MeetingDays: []string{"Tuesday"}, StartTime: "14:00", EndTime: "15:00", - Modality: "Lab", Location: &Location{Building: "ECSW", Room: "1.200", MapURI: "https://example.com/lab"}, - }, - }, - CoreFlags: []string{"030", "090"}, - SyllabusURI: "https://example.com/syllabus", - GradeDistribution: []int32{10, 8, 3, 1, 0}, - Attributes: map[string]string{"topic": "Computing"}, - } - - if diff := cmp.Diff(want, TransformSection(input)); diff != "" { - t.Fatalf("TransformSection() mismatch (-want +got):\n%s", diff) - } -} - -func TestTransformSectionNil(t *testing.T) { - if got := TransformSection(nil); got != nil { - t.Fatalf("TransformSection(nil) = %v, want nil", got) - } -} diff --git a/graphql/graph/model/models.go b/graphql/graph/model/models.go new file mode 100644 index 00000000..3880dd68 --- /dev/null +++ b/graphql/graph/model/models.go @@ -0,0 +1,71 @@ +package model + +import ( + "go.mongodb.org/mongo-driver/v2/bson" +) + +// Models that interact with MongoDB +// I.e., these models have ID reference to other models + +type Course struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + SubjectPrefix string `json:"subject_prefix" bson:"subject_prefix"` + CourseNumber string `json:"course_number" bson:"course_number"` + Title string `json:"title" bson:"title"` + Description string `json:"description" bson:"description"` + EnrollmentReqs string `json:"enrollment_reqs" bson:"enrollment_reqs"` + School string `json:"school" bson:"school"` + CreditHours string `json:"credit_hours" bson:"credit_hours"` + ClassLevel string `json:"class_level" bson:"class_level"` + ActivityType string `json:"activity_type" bson:"activity_type"` + Grading string `json:"grading" bson:"grading"` + InternalCourseNumber string `json:"internal_course_number" bson:"internal_course_number"` + Prerequisites *CollectionRequirement `json:"prerequisites,omitempty" bson:"prerequisites,omitempty"` + Corequisites *CollectionRequirement `json:"corequisites,omitempty" bson:"corequisites,omitempty"` + CoOrPreRequisites *CollectionRequirement `json:"co_or_pre_requisites,omitempty" bson:"co_or_pre_requisites,omitempty"` + Sections []bson.ObjectID `json:"sections" bson:"sections"` + LectureContactHours string `json:"lecture_contact_hours" bson:"lecture_contact_hours"` + LaboratoryContactHours string `json:"laboratory_contact_hours" bson:"laboratory_contact_hours"` + OfferingFrequency string `json:"offering_frequency" bson:"offering_frequency"` + CatalogYear string `json:"catalog_year" bson:"catalog_year"` + Attributes any `json:"attributes,omitempty" bson:"attributes,omitempty"` +} + +type Professor struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + FirstName string `json:"first_name" bson:"first_name"` + LastName string `json:"last_name" bson:"last_name"` + Titles []string `json:"titles" bson:"titles"` + Email string `json:"email" bson:"email"` + PhoneNumber string `json:"phone_number" bson:"phone_number"` + Office *Location `json:"office" bson:"office"` + ProfileURI string `json:"profile_uri" bson:"profile_uri"` + ImageURI string `json:"image_uri" bson:"image_uri"` + OfficeHours any `json:"office_hours,omitempty" bson:"office_hours,omitempty"` + Sections []bson.ObjectID `json:"sections" bson:"sections"` +} + +type Section struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + SectionNumber string `json:"section_number" bson:"section_number"` + CourseReference bson.ObjectID `json:"course_reference" bson:"course_reference"` + SectionCorequisites *CollectionRequirement `json:"section_corequisites,omitempty" bson:"section_corequisites,omitempty"` + AcademicSession *AcademicSession `json:"academic_session" bson:"academic_session"` + Professors []bson.ObjectID `json:"professors" bson:"professors"` + TeachingAssistants []*Assistant `json:"teaching_assistants" bson:"teaching_assistants"` + InternalClassNumber string `json:"internal_class_number" bson:"internal_class_number"` + InstructionMode string `json:"instruction_mode" bson:"instruction_mode"` + Meetings []*Meeting `json:"meetings" bson:"meetings"` + CoreFlags []string `json:"core_flags" bson:"core_flags"` + SyllabusURI string `json:"syllabus_uri" bson:"syllabus_uri"` + GradeDistribution []int32 `json:"grade_distribution,omitempty" bson:"grade_distribution,omitempty"` + Attributes any `json:"attributes,omitempty" bson:"attributes,omitempty"` +} + +type SectionWithTime struct { + Section bson.ObjectID `json:"section" bson:"section"` + StartTime string `json:"start_time" bson:"start_time"` + EndTime string `json:"end_time" bson:"end_time"` +} + +func (SectionWithTime) IsEventResult() {} diff --git a/graphql/graph/model/models_gen.go b/graphql/graph/model/models_gen.go index afc6eb4b..430e62c9 100644 --- a/graphql/graph/model/models_gen.go +++ b/graphql/graph/model/models_gen.go @@ -4,6 +4,8 @@ package model import ( "time" + + "go.mongodb.org/mongo-driver/v2/bson" ) type EventResult interface { @@ -11,16 +13,16 @@ type EventResult interface { } type AcademicSession struct { - Name string `json:"name"` - StartDate time.Time `json:"start_date"` - EndDate time.Time `json:"end_date"` + Name string `json:"name" bson:"name"` + StartDate time.Time `json:"start_date" bson:"start_date"` + EndDate time.Time `json:"end_date" bson:"end_date"` } type Assistant struct { - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Role string `json:"role"` - Email string `json:"email"` + FirstName string `json:"first_name" bson:"first_name"` + LastName string `json:"last_name" bson:"last_name"` + Role string `json:"role" bson:"role"` + Email string `json:"email" bson:"email"` } type AstraBuilding struct { @@ -57,14 +59,14 @@ type BuildingRooms struct { } type CollectionRequirement struct { - Type string `json:"type"` - Name string `json:"name"` - Required int32 `json:"required"` - Options any `json:"options,omitempty"` + Type string `json:"type" bson:"type"` + Name string `json:"name" bson:"name"` + Required int32 `json:"required" bson:"required"` + Options any `json:"options,omitempty" bson:"options"` } type CometCalendar struct { - ID string `json:"_id" bson:"_id"` + ID bson.ObjectID `json:"_id" bson:"_id"` Date string `json:"date" bson:"date"` Buildings []*CometCalendarBuilding `json:"buildings" bson:"buildings"` } @@ -94,30 +96,6 @@ type CometCalendarRoomInput struct { Events []*EventInput `json:"events,omitempty"` } -type Course struct { - ID string `json:"_id"` - SubjectPrefix string `json:"subject_prefix"` - CourseNumber string `json:"course_number"` - Title string `json:"title"` - Description string `json:"description"` - EnrollmentReqs string `json:"enrollment_reqs"` - School string `json:"school"` - CreditHours string `json:"credit_hours"` - ClassLevel string `json:"class_level"` - ActivityType string `json:"activity_type"` - Grading string `json:"grading"` - InternalCourseNumber string `json:"internal_course_number"` - Prerequisites *CollectionRequirement `json:"prerequisites,omitempty"` - Corequisites *CollectionRequirement `json:"corequisites,omitempty"` - CoOrPreRequisites *CollectionRequirement `json:"co_or_pre_requisites,omitempty"` - Sections []*Section `json:"sections"` - LectureContactHours string `json:"lecture_contact_hours"` - LaboratoryContactHours string `json:"laboratory_contact_hours"` - OfferingFrequency string `json:"offering_frequency"` - CatalogYear string `json:"catalog_year"` - Attributes any `json:"attributes,omitempty"` -} - type CourseFilter struct { SubjectPrefix *string `json:"subject_prefix,omitempty" bson:"subject_prefix,omitempty"` CourseNumber *string `json:"course_number,omitempty" bson:"course_number,omitempty"` @@ -134,21 +112,21 @@ type CourseFilter struct { } type Event struct { - ID string `json:"_id" bson:"_id"` - Summary string `json:"summary" bson:"summary"` - Location string `json:"location" bson:"location"` - StartTime time.Time `json:"start_time" bson:"start_time"` - EndTime time.Time `json:"end_time" bson:"end_time"` - Description string `json:"description" bson:"description"` - EventType []string `json:"event_type" bson:"event_type"` - TargetAudience []string `json:"target_audience" bson:"target_audience"` - Topic []string `json:"topic" bson:"topic"` - EventTags []string `json:"event_tags" bson:"event_tags"` - EventWebsite string `json:"event_website" bson:"event_website"` - Department []string `json:"department" bson:"department"` - ContactName string `json:"contact_name" bson:"contact_name"` - ContactEmail string `json:"contact_email" bson:"contact_email"` - ContactPhoneNumber string `json:"contact_phone_number" bson:"contact_phone_number"` + ID bson.ObjectID `json:"_id" bson:"_id"` + Summary string `json:"summary" bson:"summary"` + Location string `json:"location" bson:"location"` + StartTime time.Time `json:"start_time" bson:"start_time"` + EndTime time.Time `json:"end_time" bson:"end_time"` + Description string `json:"description" bson:"description"` + EventType []string `json:"event_type" bson:"event_type"` + TargetAudience []string `json:"target_audience" bson:"target_audience"` + Topic []string `json:"topic" bson:"topic"` + EventTags []string `json:"event_tags" bson:"event_tags"` + EventWebsite string `json:"event_website" bson:"event_website"` + Department []string `json:"department" bson:"department"` + ContactName string `json:"contact_name" bson:"contact_name"` + ContactEmail string `json:"contact_email" bson:"contact_email"` + ContactPhoneNumber string `json:"contact_phone_number" bson:"contact_phone_number"` } type EventInput struct { @@ -163,9 +141,9 @@ type EventInput struct { } type Location struct { - Building string `json:"building"` - Room string `json:"room"` - MapURI string `json:"map_uri"` + Building string `json:"building" bson:"building"` + Room string `json:"room" bson:"room"` + MapURI string `json:"map_uri" bson:"map_uri"` } type MazevoBuilding struct { @@ -196,42 +174,22 @@ type MazevoRoom struct { } type Meeting struct { - StartDate time.Time `json:"start_date"` - EndDate time.Time `json:"end_date"` - MeetingDays []string `json:"meeting_days"` - StartTime string `json:"start_time"` - EndTime string `json:"end_time"` - Modality string `json:"modality"` - Location *Location `json:"location"` + StartDate time.Time `json:"start_date" bson:"start_date"` + EndDate time.Time `json:"end_date" bson:"end_date"` + MeetingDays []string `json:"meeting_days" bson:"meeting_days"` + StartTime string `json:"start_time" bson:"start_time"` + EndTime string `json:"end_time" bson:"end_time"` + Modality string `json:"modality" bson:"modality"` + Location *Location `json:"location" bson:"location"` } type MultiBuildingEvents struct { - Date string `json:"date"` - Buildings []*SingleBuildingEvents `json:"buildings"` + Date string `json:"date" bson:"date"` + Buildings []*SingleBuildingEvents `json:"buildings" bson:"buildings"` } func (MultiBuildingEvents) IsEventResult() {} -type Office struct { - Building string `json:"building"` - MapURI string `json:"map_uri"` - Room string `json:"room"` -} - -type Professor struct { - ID string `json:"_id"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Titles []string `json:"titles"` - Email string `json:"email"` - PhoneNumber string `json:"phone_number"` - Office *Office `json:"office"` - ProfileURI string `json:"profile_uri"` - ImageURI string `json:"image_uri"` - OfficeHours any `json:"office_hours,omitempty"` - Sections []*Section `json:"sections"` -} - type ProfessorFilter struct { Email *string `json:"email,omitempty" bson:"email,omitempty"` FirstName *string `json:"first_name,omitempty" bson:"first_name,omitempty"` @@ -249,48 +207,23 @@ type Room struct { } type RoomEvents struct { - Room string `json:"room"` - SectionEvents []*SectionWithTime `json:"section_events"` + Room string `json:"room" bson:"room"` + SectionEvents []*SectionWithTime `json:"section_events" bson:"events"` } func (RoomEvents) IsEventResult() {} -type Section struct { - ID string `json:"_id"` - SectionNumber string `json:"section_number"` - CourseReference *Course `json:"course_reference"` - SectionCorequisites *CollectionRequirement `json:"section_corequisites,omitempty"` - AcademicSession *AcademicSession `json:"academic_session"` - Professors []*Professor `json:"professors"` - TeachingAssistants []*Assistant `json:"teaching_assistants"` - InternalClassNumber string `json:"internal_class_number"` - InstructionMode string `json:"instruction_mode"` - Meetings []*Meeting `json:"meetings"` - CoreFlags []string `json:"core_flags"` - SyllabusURI string `json:"syllabus_uri"` - GradeDistribution []int32 `json:"grade_distribution,omitempty"` - Attributes any `json:"attributes,omitempty"` -} - type SectionFilter struct { - SectionNumber *string `json:"section_number,omitempty" bson:"section_number,omitempty"` - CourseReference *string `json:"course_reference,omitempty" bson:"course_reference,omitempty"` - InternalClassNumber *string `json:"internal_class_number,omitempty" bson:"internal_class_number,omitempty"` - InstructionMode *string `json:"instruction_mode,omitempty" bson:"instruction_mode,omitempty"` - SyllabusURI *string `json:"syllabus_uri,omitempty" bson:"syllabus_uri,omitempty"` + SectionNumber *string `json:"section_number,omitempty" bson:"section_number,omitempty"` + CourseReference *bson.ObjectID `json:"course_reference,omitempty" bson:"course_reference,omitempty"` + InternalClassNumber *string `json:"internal_class_number,omitempty" bson:"internal_class_number,omitempty"` + InstructionMode *string `json:"instruction_mode,omitempty" bson:"instruction_mode,omitempty"` + SyllabusURI *string `json:"syllabus_uri,omitempty" bson:"syllabus_uri,omitempty"` } -type SectionWithTime struct { - Section *Section `json:"section"` - StartTime string `json:"start_time"` - EndTime string `json:"end_time"` -} - -func (SectionWithTime) IsEventResult() {} - type SingleBuildingEvents struct { - Building string `json:"building"` - Rooms []*RoomEvents `json:"rooms"` + Building string `json:"building" bson:"building"` + Rooms []*RoomEvents `json:"rooms" bson:"rooms"` } func (SingleBuildingEvents) IsEventResult() {} diff --git a/graphql/graph/model/scalars.go b/graphql/graph/model/scalars.go new file mode 100644 index 00000000..794d5d3f --- /dev/null +++ b/graphql/graph/model/scalars.go @@ -0,0 +1,28 @@ +package model + +import ( + "fmt" + "io" + + "github.com/99designs/gqlgen/graphql" + "go.mongodb.org/mongo-driver/v2/bson" +) + +// This file is for custom marshaller and unmarshaller for types not from gqlgen + +// Marshaller for ObjectID scalar type +func MarshalObjectID(id bson.ObjectID) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + _, _ = io.WriteString(w, fmt.Sprintf("%q", id.Hex())) + }) +} + +// Unmarshaller for ObjectID scalar type +func UnmarshalObjectID(v any) (bson.ObjectID, error) { + str, ok := v.(string) + if !ok { + return bson.NilObjectID, fmt.Errorf("ObjectID must be a string") + } + objectID, err := bson.ObjectIDFromHex(str) + return objectID, err +} diff --git a/graphql/graph/professor.resolvers.go b/graphql/graph/professor.resolvers.go index bbc52183..ea795d50 100644 --- a/graphql/graph/professor.resolvers.go +++ b/graphql/graph/professor.resolvers.go @@ -17,9 +17,8 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF defer cancel() var professors []*model.Professor - var dbProfessors []*model.DBProfessor - var professorQuery bson.M + professorQuery := bson.M{} if filter != nil { bsonBytes, err := bson.Marshal(filter) if err != nil { @@ -28,8 +27,6 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF if err = bson.Unmarshal(bsonBytes, &professorQuery); err != nil { return nil, err } - } else { - professorQuery = bson.M{} // no filter } paginate := options.Find().SetSkip(int64(offset)).SetLimit(configs.GetEnvLimit()) @@ -38,37 +35,28 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() - if err = cursor.All(timeoutCtx, &dbProfessors); err != nil { + if err = cursor.All(timeoutCtx, &professors); err != nil { return nil, err } - for _, dbProfessor := range dbProfessors { - professors = append(professors, model.TransformProfessor(dbProfessor)) - } - return professors, err } -func (r *queryResolver) Professor(ctx context.Context, id string) (*model.Professor, error) { +func (r *queryResolver) Professor(ctx context.Context, id bson.ObjectID) (*model.Professor, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - - dbProfessor := &model.DBProfessor{} + professor := &model.Professor{} + var err error - result := r.ProfCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(dbProfessor); err != nil { + result := r.ProfCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(professor); err != nil { return nil, err } - return model.TransformProfessor(dbProfessor), err - + return professor, err } // Sections is the resolver for the section field referenced from professor diff --git a/graphql/graph/room.resolvers.go b/graphql/graph/room.resolvers.go index b43f688e..a56493c5 100644 --- a/graphql/graph/room.resolvers.go +++ b/graphql/graph/room.resolvers.go @@ -21,7 +21,7 @@ func (r *queryResolver) Rooms(ctx context.Context) ([]*model.BuildingRooms, erro if err != nil { return buildingRooms, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() if err = cursor.All(ctx, &buildingRooms); err != nil { return buildingRooms, err diff --git a/graphql/graph/schema.graphqls b/graphql/graph/schema.graphqls index 102dd2ba..6269f400 100644 --- a/graphql/graph/schema.graphqls +++ b/graphql/graph/schema.graphqls @@ -1,15 +1,17 @@ directive @goTag(key: String!, value: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +directive @goField(forceResolver: Boolean) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION scalar Any scalar Float64 scalar DateTime +scalar ObjectID type CollectionRequirement { - type: String! - name: String! - required: Int! - options: Any + type: String! @goTag(key: "bson", value: "type") + name: String! @goTag(key: "bson", value: "name") + required: Int! @goTag(key: "bson", value: "required") + options: Any @goTag(key: "bson", value: "options") } type Course { - _id: ID! + _id: ObjectID! subject_prefix: String! course_number: String! title: String! @@ -24,7 +26,7 @@ type Course { prerequisites: CollectionRequirement corequisites: CollectionRequirement co_or_pre_requisites: CollectionRequirement - sections: [Section!]! + sections: [Section!]! @goField(forceResolver: true) lecture_contact_hours: String! laboratory_contact_hours: String! offering_frequency: String! @@ -45,23 +47,19 @@ input CourseFilter { offering_frequency: String @goTag(key: "bson", value: "offering_frequency,omitempty") catalog_year: String @goTag(key: "bson", value: "catalog_year,omitempty") } -type Office { - building: String! - map_uri: String! - room: String! -} + type Professor { - _id: ID! + _id: ObjectID! first_name: String! last_name: String! titles: [String!]! email: String! phone_number: String! - office: Office! + office: Location! profile_uri: String! image_uri: String! office_hours: Any - sections: [Section!]! + sections: [Section!]! @goField(forceResolver: true) } input ProfessorFilter { email: String @goTag(key: "bson", value: "email,omitempty") @@ -71,37 +69,37 @@ input ProfessorFilter { office_building: String @goTag(key: "bson", value: "office.building,omitempty") } type AcademicSession { - name: String! - start_date: DateTime! - end_date: DateTime! + name: String! @goTag(key: "bson", value: "name") + start_date: DateTime! @goTag(key: "bson", value: "start_date") + end_date: DateTime! @goTag(key: "bson", value: "end_date") } type Assistant { - first_name: String! - last_name: String! - role: String! - email: String! + first_name: String! @goTag(key: "bson", value: "first_name") + last_name: String! @goTag(key: "bson", value: "last_name") + role: String! @goTag(key: "bson", value: "role") + email: String! @goTag(key: "bson", value: "email") } type Location { - building: String! - room: String! - map_uri: String! + building: String! @goTag(key: "bson", value: "building") + room: String! @goTag(key: "bson", value: "room") + map_uri: String! @goTag(key: "bson", value: "map_uri") } type Meeting { - start_date: DateTime! - end_date: DateTime! - meeting_days: [String!]! - start_time: String! - end_time: String! - modality: String! - location: Location! + start_date: DateTime! @goTag(key: "bson", value: "start_date") + end_date: DateTime! @goTag(key: "bson", value: "end_date") + meeting_days: [String!]! @goTag(key: "bson", value: "meeting_days") + start_time: String! @goTag(key: "bson", value: "start_time") + end_time: String! @goTag(key: "bson", value: "end_time") + modality: String! @goTag(key: "bson", value: "modality") + location: Location! @goTag(key: "bson", value: "location") } type Section { - _id: ID! + _id: ObjectID! section_number: String! - course_reference: Course! + course_reference: Course! @goField(forceResolver: true) section_corequisites: CollectionRequirement academic_session: AcademicSession! - professors: [Professor!]! + professors: [Professor!]! @goField(forceResolver: true) teaching_assistants: [Assistant!]! internal_class_number: String! instruction_mode: String! @@ -113,7 +111,7 @@ type Section { } input SectionFilter { section_number: String @goTag(key: "bson", value: "section_number,omitempty") - course_reference: ID @goTag(key: "bson", value: "course_reference,omitempty") + course_reference: ObjectID @goTag(key: "bson", value: "course_reference,omitempty") internal_class_number: String @goTag(key: "bson", value: "internal_class_number,omitempty") instruction_mode: String @goTag(key: "bson", value: "instruction_mode,omitempty") syllabus_uri: String @goTag(key: "bson", value: "syllabus_uri,omitempty") @@ -129,19 +127,19 @@ type BuildingRooms { lon: Float64! @goTag(key: "bson", value: "lon") } type MultiBuildingEvents { - date: String! - buildings: [SingleBuildingEvents!]! + date: String! @goTag(key: "bson", value: "date") + buildings: [SingleBuildingEvents!]! @goTag(key: "bson", value: "buildings") } type SingleBuildingEvents { - building: String! - rooms: [RoomEvents!]! + building: String! @goTag(key: "bson", value: "building") + rooms: [RoomEvents!]! @goTag(key: "bson", value: "rooms") } type RoomEvents { - room: String! - section_events: [SectionWithTime!]! + room: String! @goTag(key: "bson", value: "room") + section_events: [SectionWithTime!]! @goTag(key: "bson", value: "events") } type SectionWithTime { - section: Section! + section: Section! @goField(forceResolver: true) start_time: String! end_time: String! } @@ -192,7 +190,7 @@ type MazevoDayEvents { buildings: [MazevoBuilding!]! @goTag(key: "bson", value: "buildings") } type Event { - _id: ID! @goTag(key: "bson", value: "_id") + _id: ObjectID! @goTag(key: "bson", value: "_id") summary: String! @goTag(key: "bson", value: "summary") location: String! @goTag(key: "bson", value: "location") start_time: DateTime! @goTag(key: "bson", value: "start_time") @@ -217,7 +215,7 @@ type CometCalendarBuilding { rooms: [CometCalendarRoom!]! @goTag(key: "bson", value: "rooms") } type CometCalendar { - _id: ID! @goTag(key: "bson", value: "_id") + _id: ObjectID! @goTag(key: "bson", value: "_id") date: String! @goTag(key: "bson", value: "date") buildings: [CometCalendarBuilding!]! @goTag(key: "bson", value: "buildings") } @@ -245,14 +243,14 @@ input EventInput { } type Query { courses(filter: CourseFilter, offset: Int! = 0): [Course!]! - course(id: ID!): Course + course(id: ObjectID!): Course professors(filter: ProfessorFilter, offset: Int! = 0): [Professor!]! - professor(id: ID!): Professor + professor(id: ObjectID!): Professor sections(filter: SectionFilter, offset: Int! = 0): [Section!]! - section(id: ID!): Section + section(id: ObjectID!): Section rooms: [BuildingRooms!]! cometCalendars(filter: CometCalendarFilter, offset: Int! = 0): [CometCalendar!]! - cometCalendar(id: ID!): CometCalendar + cometCalendar(id: ObjectID!): CometCalendar events(date: String!, building: String, room: String): EventResult astraEvents(date: String!): AstraDayEvents astraEventsByBuilding(date: String!, building: String!): AstraBuilding diff --git a/graphql/graph/schema.resolvers.go b/graphql/graph/schema.resolvers.go index f8160981..94f9a668 100644 --- a/graphql/graph/schema.resolvers.go +++ b/graphql/graph/schema.resolvers.go @@ -1,5 +1,10 @@ package graph +// This file will be automatically regenerated based on the schema, any resolver +// implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.98 + // Course returns CourseResolver implementation. func (r *Resolver) Course() CourseResolver { return &courseResolver{r} } @@ -15,8 +20,10 @@ func (r *Resolver) Section() SectionResolver { return §ionResolver{r} } // SectionWithTime returns SectionWithTimeResolver implementation. func (r *Resolver) SectionWithTime() SectionWithTimeResolver { return §ionWithTimeResolver{r} } -type courseResolver struct{ *Resolver } -type professorResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } -type sectionResolver struct{ *Resolver } -type sectionWithTimeResolver struct{ *Resolver } +type ( + courseResolver struct{ *Resolver } + professorResolver struct{ *Resolver } + queryResolver struct{ *Resolver } + sectionResolver struct{ *Resolver } + sectionWithTimeResolver struct{ *Resolver } +) diff --git a/graphql/graph/section.resolvers.go b/graphql/graph/section.resolvers.go index 10307ada..4fd2642e 100644 --- a/graphql/graph/section.resolvers.go +++ b/graphql/graph/section.resolvers.go @@ -13,16 +13,11 @@ import ( ) // Sections is the resolver for the sections field. -func (r *queryResolver) Sections( - ctx context.Context, - filter *model.SectionFilter, - offset int32, -) ([]*model.Section, error) { +func (r *queryResolver) Sections(ctx context.Context, filter *model.SectionFilter, offset int32) ([]*model.Section, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() var sections []*model.Section - var dbSections []*model.DBSection // building mongo query from filter (nil filter --> empty query --> return all) sectionQuery := bson.M{} @@ -44,45 +39,35 @@ func (r *queryResolver) Sections( if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() // Decode - if err := cursor.All(timeoutCtx, &dbSections); err != nil { + if err := cursor.All(timeoutCtx, §ions); err != nil { return nil, err } - for _, dbSection := range dbSections { - sections = append(sections, model.TransformSection(dbSection)) - } - return sections, nil } // Section is the resolver for the section field by ID. -func (r *queryResolver) Section(ctx context.Context, id string) (*model.Section, error) { +func (r *queryResolver) Section(ctx context.Context, id bson.ObjectID) (*model.Section, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - // decoding to a real value and not a nullptr - var dbSection model.DBSection - result := r.SectionCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(&dbSection); err != nil { + var section model.Section + var err error + + result := r.SectionCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(§ion); err != nil { return nil, err } - return model.TransformSection(&dbSection), nil + return §ion, nil } -func (r *sectionResolver) CourseReference( - ctx context.Context, - obj *model.Section, -) (*model.Course, error) { - return r.Query().Course(ctx, obj.CourseReference.ID) +func (r *sectionResolver) CourseReference(ctx context.Context, obj *model.Section) (*model.Course, error) { + return r.Query().Course(ctx, obj.CourseReference) } func (r *sectionResolver) Professors(ctx context.Context, obj *model.Section) ([]*model.Professor, error) { diff --git a/graphql/loaders/professor.go b/graphql/loaders/professor.go index 0b896859..0f00df59 100644 --- a/graphql/loaders/professor.go +++ b/graphql/loaders/professor.go @@ -19,50 +19,38 @@ func (p *professorReader) getProfessors(ctx context.Context, professorIDs []bson if err != nil { return nil, []error{err} } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() - var dbProfessors []*model.DBProfessor - if err := cursor.All(ctx, &dbProfessors); err != nil { + var professors []*model.Professor + if err := cursor.All(ctx, &professors); err != nil { return nil, []error{err} } - professorMap := make(map[bson.ObjectID]*model.Professor, len(dbProfessors)) - for _, dbProfessor := range dbProfessors { - professorMap[dbProfessor.ID] = model.TransformProfessor(dbProfessor) + professorMap := make(map[bson.ObjectID]*model.Professor, len(professors)) + for _, professor := range professors { + professorMap[professor.ID] = professor } - professors := make([]*model.Professor, len(professorIDs)) + orderedProfessors := make([]*model.Professor, len(professorIDs)) errs := make([]error, len(professorIDs)) for i, id := range professorIDs { - professors[i] = professorMap[id] - if professors[i] == nil { + orderedProfessors[i] = professorMap[id] + if orderedProfessors[i] == nil { errs[i] = mongo.ErrNoDocuments } } - return professors, errs + return orderedProfessors, errs } // GetProfessor loads a professor from a reference that contains only its ID. -func GetProfessor(ctx context.Context, professorRef *model.Professor) (*model.Professor, error) { - professorID, err := bson.ObjectIDFromHex(professorRef.ID) - if err != nil { - return nil, err - } - - return For(ctx).ProfessorLoader.Load(ctx, professorID) +func GetProfessor(ctx context.Context, professorRef bson.ObjectID) (*model.Professor, error) { + loaders := For(ctx) + return loaders.ProfessorLoader.Load(ctx, professorRef) } // GetProfessors loads professors from references that contain only their IDs. -func GetProfessors(ctx context.Context, professorsRef []*model.Professor) ([]*model.Professor, error) { - professorIDs := make([]bson.ObjectID, len(professorsRef)) - for i, professor := range professorsRef { - professorID, err := bson.ObjectIDFromHex(professor.ID) - if err != nil { - return nil, err - } - professorIDs[i] = professorID - } - - return For(ctx).ProfessorLoader.LoadAll(ctx, professorIDs) +func GetProfessors(ctx context.Context, professorsRef []bson.ObjectID) ([]*model.Professor, error) { + loaders := For(ctx) + return loaders.ProfessorLoader.LoadAll(ctx, professorsRef) } diff --git a/graphql/loaders/professor_test.go b/graphql/loaders/professor_test.go deleted file mode 100644 index 93eea452..00000000 --- a/graphql/loaders/professor_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package loaders - -import ( - "context" - "testing" - - "github.com/UTDNebula/nebula-api/graphql/graph/model" - "github.com/vikstrous/dataloadgen" - "go.mongodb.org/mongo-driver/v2/bson" -) - -func TestGetProfessorsInvalidID(t *testing.T) { - // ID validation must finish before the loader can make a database query. - refs := []*model.Professor{{ID: bson.NewObjectID().Hex()}, {ID: "invalid"}} - if _, err := GetProfessors(context.Background(), refs); err == nil { - t.Fatal("expected invalid ID error") - } - if _, err := GetProfessor(context.Background(), refs[1]); err == nil { - t.Fatal("expected invalid ID error") - } -} - -func TestGetProfessorsEmpty(t *testing.T) { - loader := dataloadgen.NewLoader(func(context.Context, []bson.ObjectID) ([]*model.Professor, []error) { - t.Error("empty references must not query the database") - return nil, nil - }) - ctx := context.WithValue(context.Background(), loadersKey, &Loaders{ProfessorLoader: loader}) - professors, err := GetProfessors(ctx, nil) - if err != nil || professors == nil || len(professors) != 0 { - t.Fatalf("expected empty list, got %v, %v", professors, err) - } -} diff --git a/graphql/loaders/section.go b/graphql/loaders/section.go index 7e36a827..cbecc34c 100644 --- a/graphql/loaders/section.go +++ b/graphql/loaders/section.go @@ -20,57 +20,43 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec if err != nil { return nil, []error{err} } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // Decode - var dbSections []*model.DBSection - if err := cursor.All(ctx, &dbSections); err != nil { + var sections []*model.Section + if err := cursor.All(ctx, §ions); err != nil { return nil, []error{err} } // $in does not return in order of given sectionIDs // so we order with map. - sectionMap := make(map[bson.ObjectID]*model.Section, len(dbSections)) - for _, dbSection := range dbSections { - sectionMap[dbSection.ID] = model.TransformSection(dbSection) + sectionMap := make(map[bson.ObjectID]*model.Section, len(sections)) + for _, section := range sections { + sectionMap[section.ID] = section } - sections := make([]*model.Section, len(sectionIDs)) + orderedSections := make([]*model.Section, len(sectionIDs)) + errs := make([]error, len(sectionIDs)) for i, ID := range sectionIDs { - sections[i] = sectionMap[ID] + orderedSections[i] = sectionMap[ID] + if orderedSections[i] == nil { + errs[i] = mongo.ErrNoDocuments + } } - return sections, nil + return orderedSections, errs } // For convenience in resolvers // GetSection returns single section by id efficiently -// Note that sectionRef contains only its ObjectID. -// All other fields in sectionRef are empty. -func GetSection(ctx context.Context, sectionRef *model.Section) (*model.Section, error) { - sectionID, err := bson.ObjectIDFromHex(sectionRef.ID) - if err != nil { - return nil, err - } - +func GetSection(ctx context.Context, sectionRef bson.ObjectID) (*model.Section, error) { loaders := For(ctx) - return loaders.SectionLoader.Load(ctx, sectionID) + return loaders.SectionLoader.Load(ctx, sectionRef) } // GetSections returns many sections by ids efficiently -// Note that sectionsRef contains only the sections' ObjectID. -// All other fields of each section in sectionsRef are empty. -func GetSections(ctx context.Context, sectionsRef []*model.Section) ([]*model.Section, error) { - sectionIDs := make([]bson.ObjectID, len(sectionsRef)) - for i, section := range sectionsRef { - sectionID, err := bson.ObjectIDFromHex(section.ID) - if err != nil { - return nil, err - } - sectionIDs[i] = sectionID - } - +func GetSections(ctx context.Context, sectionsRef []bson.ObjectID) ([]*model.Section, error) { loaders := For(ctx) - return loaders.SectionLoader.LoadAll(ctx, sectionIDs) + return loaders.SectionLoader.LoadAll(ctx, sectionsRef) } diff --git a/graphql/server.go b/graphql/server.go index 116bcb52..9fcb3b05 100644 --- a/graphql/server.go +++ b/graphql/server.go @@ -17,7 +17,7 @@ import ( ) func main() { - port := configs.GetPortString("8000") + port := configs.GetPortString() resolver := graph.Resolver{ CourseCollection: configs.GetCollection("courses"), SectionCollection: configs.GetCollection("sections"), diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go new file mode 100644 index 00000000..9d4f7d0b --- /dev/null +++ b/rest/controllers/academic_calendars.go @@ -0,0 +1,87 @@ +package controllers + +import ( + "context" + "errors" + "net/http" + "time" + + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + + "github.com/UTDNebula/nebula-api/shared/configs" + + "github.com/UTDNebula/nebula-api/rest/schema" +) + +var academicCalendarsCollection *mongo.Collection = configs.GetCollection("academicCalendars") + +// AcademicCalendarsById returns an academic calendar by its string ID. +// +// @Id academicCalendarsById +// @Router /academicCalendars/{id} [get] +// @Tags Academic Calendars +// @Description Returns the academic calendar for the given term ID. +// @Produce json +// @Param id path string true "Academic term ID, for example 26F" +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "An academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No matching academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" +func AcademicCalendarsById(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + // Academic calendar IDs are strings such as "26F", not MongoDB ObjectIDs. + id := c.Param("id") + query := bson.M{"_id": id} + + // Find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No academic calendars with the given ID") + } else { + respondWithInternalError(c, err) + } + return + } + + //return result + respond(c, http.StatusOK, "success", academicCalendar) +} + +// AcademicCalendarsCurrent returns an academic calendar marked as current. +// +// @Id academicCalendarsCurrent +// @Router /academicCalendars/current [get] +// @Tags Academic Calendars +// @Description Returns one academic calendar whose timeline is current. +// @Produce json +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "The current academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No current academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" +func AcademicCalendarsCurrent(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + query := bson.M{"timeline": "current"} + + //find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No current academic calendars") + } else { + respondWithInternalError(c, err) + } + return + } + + respond(c, http.StatusOK, "success", academicCalendar) + +} diff --git a/rest/controllers/club.go b/rest/controllers/club.go index 66b49ce9..960b8e44 100644 --- a/rest/controllers/club.go +++ b/rest/controllers/club.go @@ -2,7 +2,6 @@ package controllers import ( "context" - "database/sql" "net/http" "time" @@ -26,7 +25,7 @@ func ClubDirectoryInfo(c *gin.Context) { ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) defer cancel() - var clubsDatabase *sql.DB = configs.ConnectClubsDB() + var clubsDatabase = configs.ConnectClubsDB() id := c.Param("id") var raw []byte @@ -90,7 +89,7 @@ func ClubSearch(c *gin.Context) { ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) defer cancel() - var clubsDatabase *sql.DB = configs.ConnectClubsDB() + var clubsDatabase = configs.ConnectClubsDB() search := c.Query("q") var raw []byte @@ -106,7 +105,12 @@ func ClubSearch(c *gin.Context) { 'updated_at', (updated_at AT TIME ZONE 'UTC'), 'officers', officers, 'contacts', contacts - ) ORDER BY paradedb.score(id) DESC) as club + ) ORDER BY ( + (20.0 * word_similarity($1, coalesce(club.alias, ''))) + + (10.0 * word_similarity($1, club.name)) + + (5.0 * word_similarity($1, coalesce(array_to_string(club.tags, ' '), ''))) + + (coalesce(-1.0 * (club.search_tsv <@> to_bm25query(to_tsvector('english', $1), 'club_search_idx')), 0.0)) + ) DESC) as club FROM club JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object( @@ -116,15 +120,16 @@ func ClubSearch(c *gin.Context) { ) as contacts on TRUE JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object('name',officers.name, 'position',officers.position)) as officers FROM officers where officers.club_id = club.id - ) as officers on TRUE where id @@@ - paradedb.boolean( - should => ARRAY[ - paradedb.boost(20,paradedb.match('alias',$1,distance=>2)), - paradedb.boost(10,paradedb.match('name',$1,distance=>2)), - paradedb.boost(1,paradedb.match('description',$1,distance=>1)), - paradedb.boost(5,paradedb.match('tags',$1,distance=>1)) - ]) and id @@@ - paradedb.const_score(0.0, paradedb.term('approved','approved'::approved_enum)); + ) as officers on TRUE + WHERE ( + club.search_tsv @@ websearch_to_tsquery('english', $1) + OR word_similarity($1, club.name) >= 0.2 + OR word_similarity($1, COALESCE(club.alias, '')) >= 0.2 + OR club.name ILIKE '%' || $1 || '%' + OR club.alias ILIKE '%' || $1 || '%' + ) AND ( + 'approved' = 'approved'::approved_enum + ) `, search).Scan(&raw) if err != nil { diff --git a/rest/controllers/controller_utils.go b/rest/controllers/controller_utils.go index 7fb197b7..be16825e 100644 --- a/rest/controllers/controller_utils.go +++ b/rest/controllers/controller_utils.go @@ -56,7 +56,7 @@ func getQuery[T any](flag string, c *gin.Context) (bson.M, error) { func respondWithInternalError(c *gin.Context, err error) { // Note that we use log.Output here to be able to set the stack depth to the frame above this one (2), // which allows us to log the location this function was called from - log.Output(2, fmt.Sprintf("INTERNAL SERVER ERROR: %s", err.Error())) + _ = log.Output(2, fmt.Sprintf("INTERNAL SERVER ERROR: %s", err.Error())) // Capture error with Sentry if hub := sentrygin.GetHubFromContext(c); hub != nil { hub.WithScope(func(scope *sentry.Scope) { diff --git a/rest/controllers/course.go b/rest/controllers/course.go index 2ae14251..980c69cb 100644 --- a/rest/controllers/course.go +++ b/rest/controllers/course.go @@ -64,7 +64,7 @@ func CourseSearch(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // Retrieve and parse all valid documents if err = cursor.All(ctx, &courses); err != nil { @@ -129,7 +129,7 @@ func CourseAll(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // retrieve and parse all valid documents if err = cursor.All(ctx, &courses); err != nil { @@ -262,7 +262,7 @@ func courseAggregate[T any](flag string, c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err = cursor.All(ctx, &queryResults); err != nil { respondWithInternalError(c, err) diff --git a/rest/controllers/course_test.go b/rest/controllers/course_test.go index fab8f802..a55aae42 100644 --- a/rest/controllers/course_test.go +++ b/rest/controllers/course_test.go @@ -1,27 +1,82 @@ package controllers import ( + "encoding/json" "net/http" "net/http/httptest" "testing" + "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/v2/bson" ) -func TestCourseById_InvalidID(t *testing.T) { +func TestCourseById(t *testing.T) { gin.SetMode(gin.TestMode) - // Create a response recorder to capture the result - w := httptest.NewRecorder() - c, _ := gin.CreateTestContext(w) + testCases := []struct { + name string + id string + expectedStatus int + expectedResponseMessage string + expectedData string + }{ + { + name: "ReturnCourseSuccessfully", + id: "6afa8ba7c82a15eca4f610bb", + expectedStatus: http.StatusOK, + expectedResponseMessage: "success", + }, + { + name: "InvalidMongoId", + id: "This is invalid MongoDB ID", + expectedStatus: http.StatusBadRequest, + expectedResponseMessage: `Parameter "id" is not a valid ObjectID.`, + }, + { + name: "NoCourseFound", + id: bson.NewObjectID().Hex(), + expectedStatus: http.StatusNotFound, + expectedResponseMessage: "error", + expectedData: "No courses with given ID", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + responseRecorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(responseRecorder) + context.Request = httptest.NewRequest(http.MethodGet, "/", nil) + context.Params = []gin.Param{{Key: "id", Value: testCase.id}} + + CourseById(context) + + if responseRecorder.Code != testCase.expectedStatus { + t.Fatalf("expected status %d, got %d", testCase.expectedStatus, responseRecorder.Code) + } - // Test sending a completely invalid ID format - c.Params = []gin.Param{{Key: "id", Value: "not-an-object-id"}} + var response schema.APIResponse[json.RawMessage] + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("decode response: %v", err) + } + if response.Status != testCase.expectedStatus { + t.Errorf("expected response status %d, got %d", testCase.expectedStatus, response.Status) + } + if response.Message != testCase.expectedResponseMessage { + t.Errorf("expected response message %q, got %q", testCase.expectedResponseMessage, response.Message) + } - CourseById(c) + if testCase.expectedData == "" { + return + } - // Verify that the controller utility correctly returns a 400 Bad Request - if w.Code != http.StatusBadRequest { - t.Errorf("Expected status 400 for invalid ID, got %d", w.Code) + var responseData string + if err := json.Unmarshal(response.Data, &responseData); err != nil { + t.Fatalf("decode response data: %v", err) + } + if responseData != testCase.expectedData { + t.Errorf("expected response data %q, got %q", testCase.expectedData, responseData) + } + }) } } diff --git a/rest/controllers/degrees.go b/rest/controllers/degrees.go new file mode 100644 index 00000000..f4d057d0 --- /dev/null +++ b/rest/controllers/degrees.go @@ -0,0 +1,60 @@ +package controllers + +import ( + "context" + "net/http" + "time" + + "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/UTDNebula/nebula-api/shared/configs" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/v2/mongo" +) + +var degreesCollection *mongo.Collection = configs.GetCollection("degrees") + +// @Id degrees +// @Router /degrees [get] +// @Tags Degrees +// @Description "Returns paginated academic programs matching the query's string-typed key-value pairs. An areas_of_interest query matches any area in the program's areas_of_interest array." +// @Produce json +// @Param offset query number false "The starting position of the current page of degrees (e.g. For starting at the 17th degree, offset=16)." +// @Param name query string false "The name of the academic program" +// @Param school query string false "The school offering the academic program" +// @Param degree_options.level query string false "The level of one degree option, such as BS or MS" +// @Param degree_options.public_url query string false "The public URL of one degree option" +// @Param degree_options.cip_code query string false "The Classification of Instructional Programs code of one degree option" +// @Param areas_of_interest query string false "One area of interest for the academic program" +// @Success 200 {object} schema.APIResponse[[]schema.AcademicProgram] "A list of academic programs" +// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" +// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" +func Degrees(c *gin.Context) { + ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) + defer cancel() + + query, err := getQuery[schema.AcademicProgram]("Search", c) + if err != nil { + return + } + + optionLimit, err := configs.GetOptionLimit(&query, c) + if err != nil { + respond(c, http.StatusBadRequest, "offset is not type integer", err.Error()) + return + } + + cursor, err := degreesCollection.Find(ctx, query, optionLimit) + if err != nil { + respondWithInternalError(c, err) + return + } + defer func() { _ = cursor.Close(ctx) }() + + degrees := make([]schema.AcademicProgram, 0) + if err = cursor.All(ctx, °rees); err != nil { + respondWithInternalError(c, err) + return + } + + respond(c, http.StatusOK, "success", degrees) +} diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index 8ff31a63..a2ac8fc2 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -76,7 +76,7 @@ func DiscountSearch(c *gin.Context) { return } } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() discounts := make([]schema.DiscountProgram, 0) if err = cursor.All(ctx, &discounts); err != nil { diff --git a/rest/controllers/email.go b/rest/controllers/email.go deleted file mode 100644 index 0a6ed24d..00000000 --- a/rest/controllers/email.go +++ /dev/null @@ -1,147 +0,0 @@ -package controllers - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" - "os" - "time" - - "github.com/UTDNebula/nebula-api/rest/schema" - "github.com/gin-gonic/gin" - "github.com/wneessen/go-mail" - - cloudtasks "cloud.google.com/go/cloudtasks/apiv2" - taskspb "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb" -) - -// @Id sendEmail -// @Router /email/send [post] -// @Tags Internal -// @Description "Send an email via SMTP. This route is restricted to only Nebula Labs internal Projects." -// @Accept json -// @Produce json -// @Param request body schema.EmailRequest true "Email Request Body" -// @Param x-email-send-key header string true "The internal email send key" -// @Success 200 {object} schema.APIResponse[schema.EmailRequest] "Email Request Body" -// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" -// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" -func SendEmail(c *gin.Context) { - ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) - defer cancel() - - var req schema.EmailRequest - - if err := c.ShouldBindJSON(&req); err != nil { - respond(c, http.StatusBadRequest, "invalid request payload", err.Error()) - return - } - - client := c.MustGet("emailClient").(*mail.Client) - smtpUsername := os.Getenv("SMTP_USERNAME") - - m := mail.NewMsg() - if err := m.FromFormat(req.From, smtpUsername); err != nil { - respond(c, http.StatusInternalServerError, "failed to set from address", err.Error()) - return - } - - if err := m.To(req.To...); err != nil { - respond(c, http.StatusBadRequest, "invalid to address(es)", err.Error()) - return - } - - m.Subject(req.Subject) - m.SetBodyString(mail.TypeTextHTML, req.Body) - - for _, att := range req.Attachments { - m.AttachReader(att.Name, bytes.NewReader(att.Data)) - } - - for _, emb := range req.Embeds { - m.EmbedReader(emb.Name, bytes.NewReader(emb.Data), mail.WithFileContentID(emb.Name)) - } - - if err := client.DialAndSendWithContext(ctx, m); err != nil { - respond(c, http.StatusInternalServerError, "failed to send email", err.Error()) - return - } - - respond(c, http.StatusOK, "success", req) -} - -// @Id QueueEmail -// @Router /email/queue [post] -// @Tags Internal -// @Description "Queue an email to be sent via SMTP. Multi-recipient emails will be queued as separate emails to avoid bypassing queueing system. This route is restricted to only Nebula Labs internal Projects." -// @Accept json -// @Produce json -// @Param request body schema.EmailRequest true "Email Request Body" -// @Param x-email-queue-key header string true "The internal email queue key" -// @Success 200 {object} schema.APIResponse[[]string] "The list of queued task names" -// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" -// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" -func QueueEmail(c *gin.Context) { - // Request must be able to bind to email request - var emailReq schema.EmailRequest - if err := c.ShouldBindJSON(&emailReq); err != nil { - respond(c, http.StatusBadRequest, "invalid request payload", err.Error()) - return - } - - client := c.MustGet("tasksClient").(*cloudtasks.Client) - queuePath := os.Getenv("GCLOUD_EMAIL_QUEUE_PATH") - queueUrl := os.Getenv("GCLOUD_EMAIL_QUEUE_URL") - - baseEmailReq := emailReq - baseEmailReq.To = []string{} - - queuedTasks := []string{} - - numOfRecipients := len(emailReq.To) - for i, to := range emailReq.To { - ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) - defer cancel() - - baseEmailReq.To = []string{to} - - body, err := json.Marshal(baseEmailReq) - if err != nil { - respond(c, http.StatusInternalServerError, fmt.Sprintf("failed to serialize email request for recipient %s %d/%d", to, i, numOfRecipients), err.Error()) - return - } - - // Build the Task payload. - // // https://docs.cloud.google.com/tasks/docs/creating-http-target-tasks - taskReq := &taskspb.CreateTaskRequest{ - Parent: queuePath, - Task: &taskspb.Task{ - MessageType: &taskspb.Task_HttpRequest{ - HttpRequest: &taskspb.HttpRequest{ - HttpMethod: taskspb.HttpMethod_POST, - Url: queueUrl, - Headers: map[string]string{ - "x-email-send-key": os.Getenv("EMAIL_SEND_ROUTE_KEY"), // Must get from env bc queue only has x-email-queue-key header - "x-api-key": c.GetHeader("x-api-key"), - }, - }, - }, - }, - } - - // Add a payload message if one is present. - taskReq.Task.GetHttpRequest().Body = []byte(body) - - task, err := client.CreateTask(ctx, taskReq) - if err != nil { - respond(c, http.StatusInternalServerError, fmt.Sprintf("failed to queue email for recipient %s %d/%d", to, i, numOfRecipients), err.Error()) - return - } - - queuedTasks = append(queuedTasks, task.GetName()) - } - - respond(c, http.StatusOK, "success", queuedTasks) -} diff --git a/rest/controllers/events.go b/rest/controllers/events.go index 0bc497cd..7b499407 100644 --- a/rest/controllers/events.go +++ b/rest/controllers/events.go @@ -246,7 +246,7 @@ func SectionsByRoomDetailed(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err = cursor.All(ctx, §ionsByRoom.Events); err != nil { respondWithInternalError(c, err) diff --git a/rest/controllers/section.go b/rest/controllers/section.go index c597f00d..95ca07a3 100644 --- a/rest/controllers/section.go +++ b/rest/controllers/section.go @@ -164,6 +164,7 @@ func SectionCourseSearch(c *gin.Context) { // @Success 200 {object} schema.APIResponse[schema.Course] "A course" // @Failure 500 {object} schema.APIResponse[string] "A string describing the error" // @Failure 400 {object} schema.APIResponse[string] "A string describing the error" +// @Failure 404 {object} schema.APIResponse[string] "A string describing the error" func SectionCourseById(c *gin.Context) { sectionCourse("ById", c) } @@ -200,6 +201,10 @@ func sectionCourse(flag string, c *gin.Context) { case "Search": respond(c, http.StatusOK, "success", sectionCourses) case "ById": + if len(sectionCourses) == 0 { + respond(c, http.StatusNotFound, "error", "No section with given ID") + return + } respond(c, http.StatusOK, "success", sectionCourses[0]) } } diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go new file mode 100644 index 00000000..a7d1118e --- /dev/null +++ b/rest/controllers/section_test.go @@ -0,0 +1,82 @@ +package controllers + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/v2/bson" +) + +func TestSectionCourseById(t *testing.T) { + gin.SetMode(gin.TestMode) + + testCases := []struct { + name string + id string + expectedStatus int + expectedResponseMessage string + expectedData string + }{ + { + name: "ReturnCourseSuccessfully", + id: "6afa8ba8c82a15eca4f623f4", + expectedStatus: http.StatusOK, + expectedResponseMessage: "success", + }, + { + name: "InvalidMongoId", + id: "This is invalid MongoDB ID", + expectedStatus: http.StatusBadRequest, + expectedResponseMessage: `Parameter "id" is not a valid ObjectID.`, + }, + { + name: "NoSectionFound", + id: bson.NewObjectID().Hex(), + expectedStatus: http.StatusNotFound, + expectedResponseMessage: "error", + expectedData: "No section with given ID", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + responseRecorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(responseRecorder) + context.Request = httptest.NewRequest(http.MethodGet, "/", nil) + context.Params = []gin.Param{{Key: "id", Value: testCase.id}} + + SectionCourseById(context) + + if responseRecorder.Code != testCase.expectedStatus { + t.Fatalf("expected status %d, got %d", testCase.expectedStatus, responseRecorder.Code) + } + + var response schema.APIResponse[json.RawMessage] + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("decode response: %v", err) + } + if response.Status != testCase.expectedStatus { + t.Errorf("expected response status %d, got %d", testCase.expectedStatus, response.Status) + } + if response.Message != testCase.expectedResponseMessage { + t.Errorf("expected response message %q, got %q", testCase.expectedResponseMessage, response.Message) + } + + if testCase.expectedData == "" { + return + } + + var responseData string + if err := json.Unmarshal(response.Data, &responseData); err != nil { + t.Fatalf("decode response data: %v", err) + } + if responseData != testCase.expectedData { + t.Errorf("expected response data %q, got %q", testCase.expectedData, responseData) + } + }) + } +} diff --git a/rest/controllers/semesters.go b/rest/controllers/semesters.go new file mode 100644 index 00000000..30bb9a60 --- /dev/null +++ b/rest/controllers/semesters.go @@ -0,0 +1,28 @@ +package controllers + +import ( + "encoding/json" + "net/http" + "os" + + _ "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/UTDNebula/nebula-api/shared/configs" + "github.com/gin-gonic/gin" +) + +// @Id semesters +// @Router /semesters [get] +// @Tags Other +// @Description "Returns a list of all available terms in CourseBook, sorted by recency" +// @Produce json +// @Success 200 {object} schema.APIResponse[[]string] "A string list of all available terms, lowercased" +// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" +func Semesters(c *gin.Context) { + fileBytes, err := os.ReadFile(configs.SemestersJSONFilename) + if err != nil { + respondWithInternalError(c, err) + return + } + + respond(c, http.StatusOK, "success", json.RawMessage(fileBytes)) +} diff --git a/rest/controllers/max_upload_size_test.go b/rest/controllers/storage_test.go similarity index 80% rename from rest/controllers/max_upload_size_test.go rename to rest/controllers/storage_test.go index 359da011..e3ef10d0 100644 --- a/rest/controllers/max_upload_size_test.go +++ b/rest/controllers/storage_test.go @@ -9,21 +9,33 @@ import ( "strings" "testing" - "cloud.google.com/go/storage" + "github.com/fsouza/fake-gcs-server/fakestorage" "github.com/gin-gonic/gin" ) func TestMaxUploadSize(t *testing.T) { // Set the environment variable for max upload size (e.g., 100 bytes) - os.Setenv("MAX_UPLOAD_SIZE", "100") - defer os.Unsetenv("MAX_UPLOAD_SIZE") + + if err := os.Setenv("MAX_UPLOAD_SIZE", "100"); err != nil { + t.Fatalf("Error setting 'MAX_UPLOAD_SIZE'") + } + + defer func() { + if err := os.Unsetenv("MAX_UPLOAD_SIZE"); err != nil { + t.Fatalf("Error unsetting 'MAX_UPLOAD_SIZE'") + } + }() + + server := fakestorage.NewServer(nil) + defer server.Stop() + client := server.Client() // Setup Gin gin.SetMode(gin.TestMode) router := gin.New() router.POST("/storage/:bucket/:objectID", func(c *gin.Context) { - c.Set("gcsClient", &storage.Client{}) + c.Set("gcsClient", client) PostObject(c) }) @@ -31,7 +43,7 @@ func TestMaxUploadSize(t *testing.T) { defer func() { if r := recover(); r != nil { - + t.Fatalf("Recover panicked unexpectedly: %v", r) } }() @@ -66,8 +78,8 @@ func TestMaxUploadSize(t *testing.T) { t.Run("Upload exceeding limit via Stream", func(t *testing.T) { pr, pw := io.Pipe() go func() { - pw.Write(make([]byte, 150)) - pw.Close() + _, _ = pw.Write(make([]byte, 150)) + _ = pw.Close() }() req, _ := http.NewRequest("POST", "/storage/test-bucket/stream-file", pr) diff --git a/rest/controllers/trends.go b/rest/controllers/trends.go index 97f7e0ea..467fa10d 100644 --- a/rest/controllers/trends.go +++ b/rest/controllers/trends.go @@ -101,7 +101,7 @@ func trendsSectionSearch(flag string, c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err := cursor.All(ctx, &detailedSections); err != nil { respondWithInternalError(c, err) diff --git a/rest/docs/docs.go b/rest/docs/docs.go index 23052745..78a6d8ac 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -15,6 +15,79 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/academicCalendars/current": { + "get": { + "description": "Returns one academic calendar whose timeline is current.", + "produces": [ + "application/json" + ], + "tags": [ + "Academic Calendars" + ], + "operationId": "academicCalendarsCurrent", + "responses": { + "200": { + "description": "The current academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-schema_AcademicCalendar" + } + }, + "404": { + "description": "No current academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, + "500": { + "description": "An internal server error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, + "/academicCalendars/{id}": { + "get": { + "description": "Returns the academic calendar for the given term ID.", + "produces": [ + "application/json" + ], + "tags": [ + "Academic Calendars" + ], + "operationId": "academicCalendarsById", + "parameters": [ + { + "type": "string", + "description": "Academic term ID, for example 26F", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "An academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-schema_AcademicCalendar" + } + }, + "404": { + "description": "No matching academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, + "500": { + "description": "An internal server error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, "/astra/{date}": { "get": { "description": "\"Returns AstraEvent based on the input date\"", @@ -1070,53 +1143,65 @@ const docTemplate = `{ } } }, - "/discountPrograms": { + "/degrees": { "get": { - "description": "\"Returns list of discounts filtered using field-specific keyword searches or full-text search.\"", + "description": "\"Returns paginated academic programs matching the query's string-typed key-value pairs. An areas_of_interest query matches any area in the program's areas_of_interest array.\"", "produces": [ "application/json" ], "tags": [ - "Discounts" + "Degrees" ], - "operationId": "discountPrograms", + "operationId": "degrees", "parameters": [ + { + "type": "number", + "description": "The starting position of the current page of degrees (e.g. For starting at the 17th degree, offset=16).", + "name": "offset", + "in": "query" + }, { "type": "string", - "description": "The discount's category (exact match with suggestions).", - "name": "category", + "description": "The name of the academic program", + "name": "name", "in": "query" }, { "type": "string", - "description": "The discount's business contains this keyword (case-insensitive).", - "name": "business", + "description": "The school offering the academic program", + "name": "school", "in": "query" }, { "type": "string", - "description": "The discount's address contains this keyword (case-insensitive).", - "name": "address", + "description": "The level of one degree option, such as BS or MS", + "name": "degree_options.level", "in": "query" }, { "type": "string", - "description": "The discount's discount contains this keyword (case-insensitive).", - "name": "discount", + "description": "The public URL of one degree option", + "name": "degree_options.public_url", "in": "query" }, { "type": "string", - "description": "Full-text search, must be used alone.", - "name": "q", + "description": "The Classification of Instructional Programs code of one degree option", + "name": "degree_options.cip_code", + "in": "query" + }, + { + "type": "string", + "description": "One area of interest for the academic program", + "name": "areas_of_interest", "in": "query" } ], "responses": { "200": { - "description": "A list of discounts", + "description": "A list of academic programs", "schema": { - "$ref": "#/definitions/schema.APIResponse-array_schema_DiscountProgram" + "$ref": "#/definitions/schema.APIResponse-array_schema_AcademicProgram" } }, "400": { @@ -1134,95 +1219,53 @@ const docTemplate = `{ } } }, - "/email/queue": { - "post": { - "description": "\"Queue an email to be sent via SMTP. Multi-recipient emails will be queued as separate emails to avoid bypassing queueing system. This route is restricted to only Nebula Labs internal Projects.\"", - "consumes": [ - "application/json" - ], + "/discountPrograms": { + "get": { + "description": "\"Returns list of discounts filtered using field-specific keyword searches or full-text search.\"", "produces": [ "application/json" ], "tags": [ - "Internal" + "Discounts" ], - "operationId": "QueueEmail", + "operationId": "discountPrograms", "parameters": [ { - "description": "Email Request Body", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/schema.EmailRequest" - } + "type": "string", + "description": "The discount's category (exact match with suggestions).", + "name": "category", + "in": "query" }, { "type": "string", - "description": "The internal email queue key", - "name": "x-email-queue-key", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "The list of queued task names", - "schema": { - "$ref": "#/definitions/schema.APIResponse-array_string" - } + "description": "The discount's business contains this keyword (case-insensitive).", + "name": "business", + "in": "query" }, - "400": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } + { + "type": "string", + "description": "The discount's address contains this keyword (case-insensitive).", + "name": "address", + "in": "query" }, - "500": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } - } - } - } - }, - "/email/send": { - "post": { - "description": "\"Send an email via SMTP. This route is restricted to only Nebula Labs internal Projects.\"", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Internal" - ], - "operationId": "sendEmail", - "parameters": [ { - "description": "Email Request Body", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/schema.EmailRequest" - } + "type": "string", + "description": "The discount's discount contains this keyword (case-insensitive).", + "name": "discount", + "in": "query" }, { "type": "string", - "description": "The internal email send key", - "name": "x-email-send-key", - "in": "header", - "required": true + "description": "Full-text search, must be used alone.", + "name": "q", + "in": "query" } ], "responses": { "200": { - "description": "Email Request Body", + "description": "A list of discounts", "schema": { - "$ref": "#/definitions/schema.APIResponse-schema_EmailRequest" + "$ref": "#/definitions/schema.APIResponse-array_schema_DiscountProgram" } }, "400": { @@ -3078,6 +3121,12 @@ const docTemplate = `{ "$ref": "#/definitions/schema.APIResponse-string" } }, + "404": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, "500": { "description": "A string describing the error", "schema": { @@ -3169,6 +3218,32 @@ const docTemplate = `{ } } }, + "/semesters": { + "get": { + "description": "\"Returns a list of all available terms in CourseBook, sorted by recency\"", + "produces": [ + "application/json" + ], + "tags": [ + "Other" + ], + "operationId": "semesters", + "responses": { + "200": { + "description": "A string list of all available terms, lowercased", + "schema": { + "$ref": "#/definitions/schema.APIResponse-array_string" + } + }, + "500": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, "/storage/{bucket}": { "get": { "description": "\"Get info on a bucket. This route is restricted to only Nebula Labs internal Projects.\"", @@ -3489,6 +3564,23 @@ const docTemplate = `{ } } }, + "schema.APIResponse-array_schema_AcademicProgram": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.AcademicProgram" + } + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + } + }, "schema.APIResponse-array_schema_Autocomplete": { "type": "object", "properties": { @@ -3673,11 +3765,11 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_BucketInfo": { + "schema.APIResponse-schema_AcademicCalendar": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/schema.BucketInfo" + "$ref": "#/definitions/schema.AcademicCalendar" }, "message": { "type": "string" @@ -3687,11 +3779,11 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_Budget": { + "schema.APIResponse-schema_BucketInfo": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/schema.Budget" + "$ref": "#/definitions/schema.BucketInfo" }, "message": { "type": "string" @@ -3701,11 +3793,11 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_Club": { + "schema.APIResponse-schema_Budget": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/schema.Club" + "$ref": "#/definitions/schema.Budget" }, "message": { "type": "string" @@ -3715,11 +3807,11 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_Course": { + "schema.APIResponse-schema_Club": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/schema.Course" + "$ref": "#/definitions/schema.Club" }, "message": { "type": "string" @@ -3729,11 +3821,11 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_EmailRequest": { + "schema.APIResponse-schema_Course": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/schema.EmailRequest" + "$ref": "#/definitions/schema.Course" }, "message": { "type": "string" @@ -3939,6 +4031,146 @@ const docTemplate = `{ } } }, + "schema.AcademicCalendar": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "enrollment_opens": { + "type": "string" + }, + "last_from_waitlist": { + "type": "string" + }, + "last_readmission": { + "type": "string" + }, + "midterms_due": { + "type": "string" + }, + "no_classes": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "online_add_swap_ends": { + "type": "string" + }, + "schedule_planner_available": { + "type": "string" + }, + "sessions": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.AcademicCalendarSession" + } + }, + "timeline": { + "type": "string" + }, + "university_closings": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "url": { + "type": "string" + } + } + }, + "schema.AcademicCalendarDropDeadlines": { + "type": "object", + "properties": { + "graduate_withdrawl_ends": { + "type": "string" + }, + "undergrad_approval_required": { + "type": "string" + }, + "without_w": { + "type": "string" + } + } + }, + "schema.AcademicCalendarSession": { + "type": "object", + "properties": { + "begin": { + "type": "string" + }, + "census_day": { + "type": "string" + }, + "drop_deadlines": { + "$ref": "#/definitions/schema.AcademicCalendarDropDeadlines" + }, + "end": { + "type": "string" + }, + "exams": { + "type": "array", + "items": { + "type": "string" + } + }, + "final_grading_period": { + "type": "array", + "items": { + "type": "string" + } + }, + "last_registration": { + "type": "string" + }, + "late_registration": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "reading_days": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "schema.AcademicProgram": { + "type": "object", + "properties": { + "areas_of_interest": { + "type": "array", + "items": { + "type": "string" + } + }, + "degree_options": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Degree" + } + }, + "name": { + "type": "string" + }, + "school": { + "type": "string" + } + } + }, "schema.AcademicSession": { "type": "object", "properties": { @@ -4335,6 +4567,26 @@ const docTemplate = `{ } } }, + "schema.Degree": { + "type": "object", + "properties": { + "cip_code": { + "type": "string" + }, + "joint_program": { + "type": "boolean" + }, + "level": { + "type": "string" + }, + "public_url": { + "type": "string" + }, + "stem_designated": { + "type": "boolean" + } + } + }, "schema.DiscountProgram": { "type": "object", "properties": { @@ -4367,61 +4619,6 @@ const docTemplate = `{ } } }, - "schema.EmailAttachment": { - "type": "object", - "required": [ - "data", - "name" - ], - "properties": { - "data": { - "type": "array", - "items": { - "type": "integer" - } - }, - "name": { - "type": "string" - } - } - }, - "schema.EmailRequest": { - "type": "object", - "required": [ - "body", - "subject", - "to" - ], - "properties": { - "attachments": { - "type": "array", - "items": { - "$ref": "#/definitions/schema.EmailAttachment" - } - }, - "body": { - "type": "string" - }, - "embeds": { - "type": "array", - "items": { - "$ref": "#/definitions/schema.EmailAttachment" - } - }, - "from": { - "type": "string" - }, - "subject": { - "type": "string" - }, - "to": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, "schema.Event": { "type": "object", "properties": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 261100bb..3d5988bf 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -10,6 +10,17 @@ definitions: status: type: integer type: object + schema.APIResponse-array_schema_AcademicProgram: + properties: + data: + items: + $ref: '#/definitions/schema.AcademicProgram' + type: array + message: + type: string + status: + type: integer + type: object schema.APIResponse-array_schema_Autocomplete: properties: data: @@ -129,6 +140,15 @@ definitions: status: type: integer type: object + schema.APIResponse-schema_AcademicCalendar: + properties: + data: + $ref: '#/definitions/schema.AcademicCalendar' + message: + type: string + status: + type: integer + type: object schema.APIResponse-schema_BucketInfo: properties: data: @@ -165,15 +185,6 @@ definitions: status: type: integer type: object - schema.APIResponse-schema_EmailRequest: - properties: - data: - $ref: '#/definitions/schema.EmailRequest' - message: - type: string - status: - type: integer - type: object schema.APIResponse-schema_MultiBuildingEvents-schema_AstraEvent: properties: data: @@ -300,6 +311,98 @@ definitions: status: type: integer type: object + schema.AcademicCalendar: + properties: + _id: + type: string + enrollment_opens: + type: string + last_from_waitlist: + type: string + last_readmission: + type: string + midterms_due: + type: string + no_classes: + items: + items: + type: string + type: array + type: array + online_add_swap_ends: + type: string + schedule_planner_available: + type: string + sessions: + items: + $ref: '#/definitions/schema.AcademicCalendarSession' + type: array + timeline: + type: string + university_closings: + items: + items: + type: string + type: array + type: array + url: + type: string + type: object + schema.AcademicCalendarDropDeadlines: + properties: + graduate_withdrawl_ends: + type: string + undergrad_approval_required: + type: string + without_w: + type: string + type: object + schema.AcademicCalendarSession: + properties: + begin: + type: string + census_day: + type: string + drop_deadlines: + $ref: '#/definitions/schema.AcademicCalendarDropDeadlines' + end: + type: string + exams: + items: + type: string + type: array + final_grading_period: + items: + type: string + type: array + last_registration: + type: string + late_registration: + items: + type: string + type: array + name: + type: string + reading_days: + items: + type: string + type: array + type: object + schema.AcademicProgram: + properties: + areas_of_interest: + items: + type: string + type: array + degree_options: + items: + $ref: '#/definitions/schema.Degree' + type: array + name: + type: string + school: + type: string + type: object schema.AcademicSession: properties: end_date: @@ -559,6 +662,19 @@ definitions: title: type: string type: object + schema.Degree: + properties: + cip_code: + type: string + joint_program: + type: boolean + level: + type: string + public_url: + type: string + stem_designated: + type: boolean + type: object schema.DiscountProgram: properties: _id: @@ -580,43 +696,6 @@ definitions: website: type: string type: object - schema.EmailAttachment: - properties: - data: - items: - type: integer - type: array - name: - type: string - required: - - data - - name - type: object - schema.EmailRequest: - properties: - attachments: - items: - $ref: '#/definitions/schema.EmailAttachment' - type: array - body: - type: string - embeds: - items: - $ref: '#/definitions/schema.EmailAttachment' - type: array - from: - type: string - subject: - type: string - to: - items: - type: string - type: array - required: - - body - - subject - - to - type: object schema.Event: properties: _id: @@ -1161,6 +1240,54 @@ info: title: dev-nebula-api version: 1.1.0 paths: + /academicCalendars/{id}: + get: + description: Returns the academic calendar for the given term ID. + operationId: academicCalendarsById + parameters: + - description: Academic term ID, for example 26F + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: An academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-schema_AcademicCalendar' + "404": + description: No matching academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-string' + "500": + description: An internal server error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Academic Calendars + /academicCalendars/current: + get: + description: Returns one academic calendar whose timeline is current. + operationId: academicCalendarsCurrent + produces: + - application/json + responses: + "200": + description: The current academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-schema_AcademicCalendar' + "404": + description: No current academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-string' + "500": + description: An internal server error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Academic Calendars /astra/{date}: get: description: '"Returns AstraEvent based on the input date"' @@ -1885,76 +2012,50 @@ paths: $ref: '#/definitions/schema.APIResponse-string' tags: - Courses - /discountPrograms: + /degrees: get: - description: '"Returns list of discounts filtered using field-specific keyword - searches or full-text search."' - operationId: discountPrograms + description: '"Returns paginated academic programs matching the query''s string-typed + key-value pairs. An areas_of_interest query matches any area in the program''s + areas_of_interest array."' + operationId: degrees parameters: - - description: The discount's category (exact match with suggestions). + - description: The starting position of the current page of degrees (e.g. For + starting at the 17th degree, offset=16). in: query - name: category + name: offset + type: number + - description: The name of the academic program + in: query + name: name type: string - - description: The discount's business contains this keyword (case-insensitive). + - description: The school offering the academic program in: query - name: business + name: school type: string - - description: The discount's address contains this keyword (case-insensitive). + - description: The level of one degree option, such as BS or MS in: query - name: address + name: degree_options.level type: string - - description: The discount's discount contains this keyword (case-insensitive). + - description: The public URL of one degree option in: query - name: discount + name: degree_options.public_url type: string - - description: Full-text search, must be used alone. + - description: The Classification of Instructional Programs code of one degree + option in: query - name: q + name: degree_options.cip_code type: string - produces: - - application/json - responses: - "200": - description: A list of discounts - schema: - $ref: '#/definitions/schema.APIResponse-array_schema_DiscountProgram' - "400": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - "500": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - tags: - - Discounts - /email/queue: - post: - consumes: - - application/json - description: '"Queue an email to be sent via SMTP. Multi-recipient emails will - be queued as separate emails to avoid bypassing queueing system. This route - is restricted to only Nebula Labs internal Projects."' - operationId: QueueEmail - parameters: - - description: Email Request Body - in: body - name: request - required: true - schema: - $ref: '#/definitions/schema.EmailRequest' - - description: The internal email queue key - in: header - name: x-email-queue-key - required: true + - description: One area of interest for the academic program + in: query + name: areas_of_interest type: string produces: - application/json responses: "200": - description: The list of queued task names + description: A list of academic programs schema: - $ref: '#/definitions/schema.APIResponse-array_string' + $ref: '#/definitions/schema.APIResponse-array_schema_AcademicProgram' "400": description: A string describing the error schema: @@ -1964,33 +2065,40 @@ paths: schema: $ref: '#/definitions/schema.APIResponse-string' tags: - - Internal - /email/send: - post: - consumes: - - application/json - description: '"Send an email via SMTP. This route is restricted to only Nebula - Labs internal Projects."' - operationId: sendEmail + - Degrees + /discountPrograms: + get: + description: '"Returns list of discounts filtered using field-specific keyword + searches or full-text search."' + operationId: discountPrograms parameters: - - description: Email Request Body - in: body - name: request - required: true - schema: - $ref: '#/definitions/schema.EmailRequest' - - description: The internal email send key - in: header - name: x-email-send-key - required: true + - description: The discount's category (exact match with suggestions). + in: query + name: category + type: string + - description: The discount's business contains this keyword (case-insensitive). + in: query + name: business + type: string + - description: The discount's address contains this keyword (case-insensitive). + in: query + name: address + type: string + - description: The discount's discount contains this keyword (case-insensitive). + in: query + name: discount + type: string + - description: Full-text search, must be used alone. + in: query + name: q type: string produces: - application/json responses: "200": - description: Email Request Body + description: A list of discounts schema: - $ref: '#/definitions/schema.APIResponse-schema_EmailRequest' + $ref: '#/definitions/schema.APIResponse-array_schema_DiscountProgram' "400": description: A string describing the error schema: @@ -2000,7 +2108,7 @@ paths: schema: $ref: '#/definitions/schema.APIResponse-string' tags: - - Internal + - Discounts /events/{date}: get: description: '"Returns all sections with meetings on the specified date"' @@ -3027,6 +3135,10 @@ paths: description: A string describing the error schema: $ref: '#/definitions/schema.APIResponse-string' + "404": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' "500": description: A string describing the error schema: @@ -3324,6 +3436,24 @@ paths: $ref: '#/definitions/schema.APIResponse-string' tags: - Sections + /semesters: + get: + description: '"Returns a list of all available terms in CourseBook, sorted by + recency"' + operationId: semesters + produces: + - application/json + responses: + "200": + description: A string list of all available terms, lowercased + schema: + $ref: '#/definitions/schema.APIResponse-array_string' + "500": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Other /storage/{bucket}: delete: description: '"Delete a bucket. This route is restricted to only Nebula Labs diff --git a/rest/routes/academic_calendars.go b/rest/routes/academic_calendars.go new file mode 100644 index 00000000..2feeb93a --- /dev/null +++ b/rest/routes/academic_calendars.go @@ -0,0 +1,15 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func AcademicCalendarRoute(router *gin.Engine) { + //All routes related to academic calendars route through here + academicCalendarsGroup := router.Group("/academicCalendars") + + academicCalendarsGroup.OPTIONS("", controllers.Preflight) + academicCalendarsGroup.GET(":id", controllers.AcademicCalendarsById) + academicCalendarsGroup.GET("/current", controllers.AcademicCalendarsCurrent) +} diff --git a/rest/routes/club.go b/rest/routes/club.go index 48b1b40f..f8c4fb5a 100644 --- a/rest/routes/club.go +++ b/rest/routes/club.go @@ -1,12 +1,23 @@ package routes import ( + "log" + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/UTDNebula/nebula-api/shared/configs" "github.com/gin-gonic/gin" ) func ClubRoute(router *gin.Engine) { - // All routes related to courses come here + db := configs.ConnectClubsDB() + + // Skip accessing Clubs DB if CLUBS_DB_URI is not provided. + if db == nil { + log.Println("Skipping club routes.") + return + } + + // All routes related to clubs come here. clubGroup := router.Group("/club") clubGroup.OPTIONS("", controllers.Preflight) diff --git a/rest/routes/degrees.go b/rest/routes/degrees.go new file mode 100644 index 00000000..17d41050 --- /dev/null +++ b/rest/routes/degrees.go @@ -0,0 +1,14 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func DegreesRoute(router *gin.Engine) { + // All routes related to degrees come here + degreesGroup := router.Group("/degrees") + + degreesGroup.OPTIONS("", controllers.Preflight) + degreesGroup.GET("", controllers.Degrees) +} diff --git a/rest/routes/email.go b/rest/routes/email.go deleted file mode 100644 index bb802e57..00000000 --- a/rest/routes/email.go +++ /dev/null @@ -1,122 +0,0 @@ -package routes - -import ( - "context" - "log" - "net/http" - "os" - "sync" - - cloudtasks "cloud.google.com/go/cloudtasks/apiv2" - "github.com/gin-gonic/gin" - "github.com/wneessen/go-mail" - - "github.com/UTDNebula/nebula-api/rest/controllers" - "github.com/UTDNebula/nebula-api/rest/schema" -) - -var emailClient *mail.Client -var emailClientOnce sync.Once - -var tasksClient *cloudtasks.Client -var tasksClientOnce sync.Once - -func initTasksClient() *cloudtasks.Client { - // Singleton to prevent multiple clients - tasksClientOnce.Do(func() { - - // Checking if env variables are set to know whether or not to skip the route - qPath := os.Getenv("GCLOUD_EMAIL_QUEUE_PATH") - qUrl := os.Getenv("GCLOUD_EMAIL_QUEUE_URL") - - if qPath == "" || qUrl == "" { - log.Println("Cloud Tasks environment variables are not fully configured; skipping email queuing routes") - return - } - - ctx := context.Background() - c, err := cloudtasks.NewClient(ctx) - if err != nil { - log.Printf("Failed to create Cloud Tasks client: %v", err) - return - } - tasksClient = c - }) - return tasksClient -} - -func initEmailClient() *mail.Client { - // Singleton to prevent multiple clients - emailClientOnce.Do(func() { - - // Checking if env variables are set to know whether or not to skip the route - smtpHost := os.Getenv("SMTP_HOST") - smtpUser := os.Getenv("SMTP_USERNAME") - smtpPass := os.Getenv("SMTP_PASSWORD") - sendKey := os.Getenv("EMAIL_SEND_ROUTE_KEY") - - if smtpHost == "" || smtpUser == "" || smtpPass == "" || sendKey == "" { - log.Println("SMTP environment variables are not fully configured; skipping email routes") - return - } - - c, err := mail.NewClient( - smtpHost, - mail.WithTLSPortPolicy(mail.TLSMandatory), - mail.WithSMTPAuth(mail.SMTPAuthAutoDiscover), - mail.WithUsername(smtpUser), - mail.WithPassword(smtpPass), - ) - if err != nil { - log.Printf("Failed to create SMTP client: %v", err) - return - } - emailClient = c - }) - return emailClient -} - -func EmailRoute(router *gin.Engine) { - eClient := initEmailClient() - tClient := initTasksClient() - - if eClient == nil { - log.Println("SMTP client not initialized") - } - - if tClient == nil { - log.Println("Cloud Tasks client not initialized") - } - - if eClient == nil || tClient == nil { - log.Println("skipping email routes") - return - } - - // Restrict with password - authMiddleware := func(key string, envKey string) gin.HandlerFunc { - return func(c *gin.Context) { - secret := c.GetHeader(key) - expected, exist := os.LookupEnv(envKey) - if !exist || secret != expected { - c.AbortWithStatusJSON(http.StatusForbidden, schema.APIResponse[string]{Status: http.StatusForbidden, Message: "error", Data: "Forbidden"}) - return - } - c.Next() - } - } - - // All routes related to email come here - emailGroup := router.Group("/email") - - // Pass to next layer - emailGroup.Use(func(c *gin.Context) { - c.Set("emailClient", eClient) - c.Set("tasksClient", tClient) - c.Next() - }) - - emailGroup.OPTIONS("", controllers.Preflight) - emailGroup.POST("/send", authMiddleware("x-email-send-key", "EMAIL_SEND_ROUTE_KEY"), controllers.SendEmail) - emailGroup.POST("/queue", authMiddleware("x-email-queue-key", "EMAIL_QUEUE_ROUTE_KEY"), controllers.QueueEmail) -} diff --git a/rest/routes/semesters.go b/rest/routes/semesters.go new file mode 100644 index 00000000..91998a2f --- /dev/null +++ b/rest/routes/semesters.go @@ -0,0 +1,14 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func SemestersRoute(router *gin.Engine) { + // All routes related to semesters come here + semestersGroup := router.Group("/semesters") + + semestersGroup.OPTIONS("", controllers.Preflight) + semestersGroup.GET("", controllers.Semesters) +} diff --git a/rest/schema/filter.go b/rest/schema/filter.go index 7f1c68a4..8944154e 100644 --- a/rest/schema/filter.go +++ b/rest/schema/filter.go @@ -141,7 +141,8 @@ func recBuild(t reflect.Type, prefix string, queryableMap map[string]bool, visit // Pointer types are allowed to recur once, i.e., only considered a loop when // the same pointer type appears twice in a row. func willCreateLoop(visited []reflect.Type, value reflect.Type) bool { - if value.Kind() != reflect.Ptr { + if value.Kind() != + reflect.Pointer { return false } @@ -155,7 +156,7 @@ func willCreateLoop(visited []reflect.Type, value reflect.Type) bool { // drillType gets the base of a type, removing pointers and slices/arrays func drillType(t reflect.Type) reflect.Type { - for t.Kind() == reflect.Ptr || t.Kind() == reflect.Slice || t.Kind() == reflect.Array { + for t.Kind() == reflect.Pointer || t.Kind() == reflect.Slice || t.Kind() == reflect.Array { t = t.Elem() } return t diff --git a/rest/schema/filter_test.go b/rest/schema/filter_test.go index d23d46cb..82e0ace7 100644 --- a/rest/schema/filter_test.go +++ b/rest/schema/filter_test.go @@ -144,6 +144,21 @@ func TestFilterQuery(t *testing.T) { "nested.number": "0", }, }, + "Academic program": { + Function: FilterQuery[AcademicProgram], + UrlQuery: map[string][]string{ + "name": {"Computer Science"}, + "school": {"Erik Jonsson School of Engineering"}, + "degree_options.level": {"BS"}, + "areas_of_interest": {"computer science"}, + }, + Expected: bson.M{ + "name": "Computer Science", + "school": "Erik Jonsson School of Engineering", + "degree_options.level": "BS", + "areas_of_interest": "computer science", + }, + }, "Multiple values": { Function: FilterQuery[_nested], UrlQuery: map[string][]string{ diff --git a/rest/schema/objects.go b/rest/schema/objects.go index 8fd21635..b59c56d0 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -350,16 +350,17 @@ type AcademicCalendarDropDeadlines struct { } type AcademicProgram struct { - Title string `bson:"name" json:"name"` - School string `bson:"school" json:"school"` - DegreeOptions []Degree `bson:"degree_options" json:"degree_options"` - AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Title string `bson:"name" json:"name" queryable:""` + School string `bson:"school" json:"school" queryable:""` + DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` + AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` } type Degree struct { - Level string `bson:"level" json:"level"` - PublicUrl string `bson:"public_url" json:"public_url"` - CipCode string `bson:"cip_code" json:"cip_code"` + Level string `bson:"level" json:"level" queryable:""` + PublicUrl string `bson:"public_url" json:"public_url" queryable:""` + CipCode string `bson:"cip_code" json:"cip_code" queryable:""` StemDesignated bool `bson:"stem_designated" json:"stem_designated"` JointProgram bool `bson:"joint_program" json:"joint_program"` } diff --git a/rest/schema/requirements.go b/rest/schema/requirements.go index 622e047b..1ec6bf81 100644 --- a/rest/schema/requirements.go +++ b/rest/schema/requirements.go @@ -113,51 +113,75 @@ func (cr *CollectionRequirement) UnmarshalBSON(data []byte) error { switch optionType { case "course": var t CourseRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "section": var t SectionRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "major": var t MajorRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "minor": var t MinorRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "gpa": var t GPARequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "consent": var t ConsentRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "collection": var t CollectionRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "hours": var t HoursRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "other": var t OtherRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "choice": var t ChoiceRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "limit": var t LimitRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "core": var t CoreRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) default: return fmt.Errorf("unknown option type: %v", err) diff --git a/rest/server.go b/rest/server.go index d76357ef..6dd62dc7 100644 --- a/rest/server.go +++ b/rest/server.go @@ -2,6 +2,7 @@ package main import ( "log" + "net/http" _ "github.com/UTDNebula/nebula-api/rest/docs" "github.com/UTDNebula/nebula-api/rest/routes" @@ -48,9 +49,15 @@ func main() { sharedconfigs.ConnectDB() sharedconfigs.ConnectClubsDB() + // Create JSON file for /semesters endpoint + err := sharedconfigs.CreateSemestersJSON() + if err != nil { + log.Fatalf("Unable to create Semesters JSON") + } + // Set up Sentry if err := sentry.Init(sentry.ClientOptions{ - Dsn: "https://530f8e39f757b71ab26ad1aa12e17a4d@o4504918397353984.ingest.us.sentry.io/4509397160493056", + Dsn: sharedconfigs.GetEnvSentryDSN(), TracesSampleRate: 1.0, EnableTracing: true, }); err != nil { @@ -60,7 +67,9 @@ func main() { // Configure Gin Router router := gin.New() // Get rid of "trusted all proxies" warning -- we don't care - router.SetTrustedProxies(nil) + if err := router.SetTrustedProxies(nil); err != nil { + return + } // Enable CORS router.Use(CORS) @@ -74,7 +83,13 @@ func main() { // Setup swagger-ui hosted router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + // Redirect users to swagger documentation + router.GET("/", func(r *gin.Context) { + r.Redirect(http.StatusFound, "/swagger/index.html") + }) + // Connect Routes + routes.AcademicCalendarRoute(router) routes.CourseRoute(router) routes.SectionRoute(router) routes.ProfessorRoute(router) @@ -87,16 +102,19 @@ func main() { routes.AstraRoute(router) routes.MazevoRoute(router) routes.CalendarRoute(router) + routes.DegreesRoute(router) routes.ClubRoute(router) routes.DiscountRoutes(router) - routes.EmailRoute(router) routes.BudgetRoute(router) + routes.SemestersRoute(router) // Retrieve the port string to serve traffic on - portString := ":" + sharedconfigs.GetPortString("8080") + portString := ":" + sharedconfigs.GetPortString() // Serve Traffic - router.Run(portString) + if err := router.Run(portString); err != nil { + return + } } func CORS(c *gin.Context) { diff --git a/shared/configs/env.go b/shared/configs/env.go index 6cd0fe68..8bd45ada 100644 --- a/shared/configs/env.go +++ b/shared/configs/env.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "strconv" + "sync" "github.com/joho/godotenv" ) @@ -29,10 +30,20 @@ func init() { } } -func GetPortString(defaultPort string) string { - portNumber, exists := os.LookupEnv("PORT") - if !exists { - portNumber = defaultPort +// A misconfigured variable is a single, process-wide mistake, but these readers +// run on every request that paginates or uploads. Each warning therefore fires +// at most once per process rather than once per request. +var ( + limitWarnOnce sync.Once + uploadSizeWarnOnce sync.Once + uploadSizeCapWarnOnce sync.Once +) + +func GetPortString() string { + + portNumber, exist := os.LookupEnv("PORT") + if !exist { + portNumber = "8080" } return portNumber @@ -47,6 +58,15 @@ func GetEnvMongoURI() string { return uri } +func GetClubsDBUri() string { + uri, exist := os.LookupEnv("CLUBS_DB_URI") + if !exist { + log.Println("Error loading 'CLUBS_DB_URI' from the .env file") + } + + return uri +} + func GetEnvLogin() (netID string, password string) { netID, exists := os.LookupEnv("LOGIN_NETID") if !exists { @@ -70,21 +90,15 @@ func GetEnvLimit() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { + limitWarnOnce.Do(func() { + log.Printf("Ignoring 'LIMIT' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + }) return defaultLimit } return limit } -func GetClubsDBUri() string { - uri, exists := os.LookupEnv("CLUBS_DB_URI") - if !exists { - log.Panic("Error loading 'CLUBS_DB_URI' from the .env file") - } - - return uri -} - func GetEnvMaxUploadSize() int64 { const ( defaultLimit int64 = 30 * 1024 * 1024 @@ -98,12 +112,26 @@ func GetEnvMaxUploadSize() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { + uploadSizeWarnOnce.Do(func() { + log.Printf("Ignoring 'MAX_UPLOAD_SIZE' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + }) return defaultLimit } if limit > hardCapLimit { + uploadSizeCapWarnOnce.Do(func() { + log.Printf("Capping 'MAX_UPLOAD_SIZE' of %d to the maximum of %d\n", limit, hardCapLimit) + }) return hardCapLimit } return limit } + +func GetEnvSentryDSN() string { + + // Sentry is disabled when initialized without a DSN, so an unset + // SENTRY_DSN keeps development errors out of Sentry. Only production + // sets this variable. + return os.Getenv("SENTRY_DSN") +} diff --git a/shared/configs/env_test.go b/shared/configs/env_test.go new file mode 100644 index 00000000..c783dfd0 --- /dev/null +++ b/shared/configs/env_test.go @@ -0,0 +1,358 @@ +package configs + +import ( + "bytes" + "log" + "os" + "os/exec" + "strings" + "sync" + "testing" +) + +// The environment readers below exit through log.Fatalf when a required +// variable is missing, which would take the test binary down with them. Each +// case is instead run in a subprocess that calls the reader directly, so the +// exit status can be observed. +const fatalCaseVar = "NEBULA_ENV_FATAL_CASE" + +var fatalCases = map[string]func(){ + "mongo_uri": func() { GetEnvMongoURI() }, + "login_netid": func() { GetEnvLogin() }, + "login_password": func() { + if err := os.Setenv("LOGIN_NETID", "abc123456"); err != nil { + log.Fatalf("Error setting 'LOGIN_NETID'") + } + GetEnvLogin() + }, +} + +// unsetEnv removes a variable for the duration of the test, restoring whatever +// value it had once the test finishes. +func unsetEnv(t *testing.T, key string) { + t.Helper() + + // t.Setenv records the original value so it is restored on cleanup; the + // unset immediately afterwards is what the test actually wants. + t.Setenv(key, "") + if err := os.Unsetenv(key); err != nil { + t.Fatalf("Error unsetting key") + } + +} + +// TestEnvFatalSubprocess is the entry point for the subprocesses spawned by +// runFatalCase. It does nothing during a normal test run. +func TestEnvFatalSubprocess(t *testing.T) { + + name := os.Getenv(fatalCaseVar) + if name == "" { + t.Skip("not running as a fatal-case subprocess") + } + + fatalCase, ok := fatalCases[name] + if !ok { + t.Fatalf("unknown fatal case %q", name) + } + + fatalCase() +} + +// runFatalCase re-runs this test binary with only TestEnvFatalSubprocess +// enabled, and returns the resulting exit code. +func runFatalCase(t *testing.T, name string) int { + t.Helper() + + executable, err := os.Executable() + if err != nil { + t.Fatalf("could not locate the test binary: %v", err) + } + + cmd := exec.Command(executable, "-test.run", "^TestEnvFatalSubprocess$") + cmd.Env = []string{fatalCaseVar + "=" + name} + + // Run from an empty directory so the subprocess cannot pick up a + // contributor's .env while walking up from the package directory. + cmd.Dir = t.TempDir() + + err = cmd.Run() + + exitError, isExitError := err.(*exec.ExitError) + switch { + case err == nil: + return 0 + case isExitError: + return exitError.ExitCode() + default: + t.Fatalf("could not run the fatal case %q: %v", name, err) + return -1 + } +} + +// captureLog redirects the standard logger for the duration of the test and +// returns what was written to it. +func captureLog(t *testing.T) *bytes.Buffer { + t.Helper() + + var captured bytes.Buffer + + originalOutput := log.Writer() + originalFlags := log.Flags() + log.SetOutput(&captured) + log.SetFlags(0) + + t.Cleanup(func() { + log.SetOutput(originalOutput) + log.SetFlags(originalFlags) + }) + + return &captured +} + +// resetEnvWarnings clears the once-guards so a test can observe a warning that +// an earlier test has already consumed. +func resetEnvWarnings(t *testing.T) { + t.Helper() + + limitWarnOnce = sync.Once{} + uploadSizeWarnOnce = sync.Once{} + uploadSizeCapWarnOnce = sync.Once{} +} + +func TestGetPortString(t *testing.T) { + + t.Run("Unset returns the default port", func(t *testing.T) { + + unsetEnv(t, "PORT") + + if port := GetPortString(); port != "8080" { + t.Errorf("expected \"8080\" when PORT is unset, got %q", port) + } + }) + + t.Run("Set returns the configured port", func(t *testing.T) { + + t.Setenv("PORT", "3000") + + if port := GetPortString(); port != "3000" { + t.Errorf("expected \"3000\", got %q", port) + } + }) +} + +func TestGetEnvMongoURI(t *testing.T) { + + t.Run("Set returns the URI", func(t *testing.T) { + + const expected = "mongodb://localhost:27017" + t.Setenv("MONGODB_URI", expected) + + if uri := GetEnvMongoURI(); uri != expected { + t.Errorf("expected %q, got %q", expected, uri) + } + }) + + t.Run("Unset exits", func(t *testing.T) { + + if code := runFatalCase(t, "mongo_uri"); code != 1 { + t.Errorf("expected exit code 1 when MONGODB_URI is unset, got %d", code) + } + }) +} + +func TestGetClubsDBUri(t *testing.T) { + + t.Run("Set returns the URI", func(t *testing.T) { + + const expected = "mongodb://localhost:27017/clubs" + t.Setenv("CLUBS_DB_URI", expected) + + if uri := GetClubsDBUri(); uri != expected { + t.Errorf("expected %q, got %q", expected, uri) + } + }) +} + +func TestGetEnvLogin(t *testing.T) { + + t.Run("Set returns both values", func(t *testing.T) { + + const ( + expectedNetID = "abc123456" + expectedPassword = "hunter2" + ) + t.Setenv("LOGIN_NETID", expectedNetID) + t.Setenv("LOGIN_PASSWORD", expectedPassword) + + netID, password := GetEnvLogin() + + if netID != expectedNetID { + t.Errorf("expected net ID %q, got %q", expectedNetID, netID) + } + if password != expectedPassword { + t.Errorf("expected password %q, got %q", expectedPassword, password) + } + }) + + t.Run("Missing net ID exits", func(t *testing.T) { + + if code := runFatalCase(t, "login_netid"); code != 1 { + t.Errorf("expected exit code 1 when LOGIN_NETID is unset, got %d", code) + } + }) + + t.Run("Missing password exits", func(t *testing.T) { + + if code := runFatalCase(t, "login_password"); code != 1 { + t.Errorf("expected exit code 1 when LOGIN_PASSWORD is unset, got %d", code) + } + }) +} + +func TestGetEnvLimit(t *testing.T) { + + const defaultLimit int64 = 20 + + t.Run("Unset returns the default limit", func(t *testing.T) { + + unsetEnv(t, "LIMIT") + + if limit := GetEnvLimit(); limit != defaultLimit { + t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) + } + }) + + t.Run("Set returns the parsed limit without warning", func(t *testing.T) { + + t.Setenv("LIMIT", "50") + resetEnvWarnings(t) + captured := captureLog(t) + + if limit := GetEnvLimit(); limit != 50 { + t.Errorf("expected 50, got %d", limit) + } + + if logged := captured.String(); logged != "" { + t.Errorf("expected no log output for a valid LIMIT, got %q", logged) + } + }) + + t.Run("Unparseable falls back to the default limit and warns", func(t *testing.T) { + + t.Setenv("LIMIT", "not-a-number") + resetEnvWarnings(t) + captured := captureLog(t) + + if limit := GetEnvLimit(); limit != defaultLimit { + t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) + } + + logged := captured.String() + for _, want := range []string{"LIMIT", "not-a-number", "20"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } + } + }) + + t.Run("Warns only once per process", func(t *testing.T) { + + t.Setenv("LIMIT", "not-a-number") + resetEnvWarnings(t) + captured := captureLog(t) + + GetEnvLimit() + GetEnvLimit() + GetEnvLimit() + + // GetEnvLimit runs on every paginated request, so a misconfigured + // LIMIT must not log once per request. + if lines := strings.Count(captured.String(), "\n"); lines != 1 { + t.Errorf("expected exactly 1 warning across 3 calls, got %d: %q", lines, captured.String()) + } + }) +} + +func TestGetEnvMaxUploadSize(t *testing.T) { + + const ( + defaultLimit int64 = 30 * 1024 * 1024 + hardCapLimit int64 = 50 * 1024 * 1024 + ) + + t.Run("Unset returns the default size", func(t *testing.T) { + + unsetEnv(t, "MAX_UPLOAD_SIZE") + + if size := GetEnvMaxUploadSize(); size != defaultLimit { + t.Errorf("expected the default size %d, got %d", defaultLimit, size) + } + }) + + t.Run("Set returns the parsed size", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "100") + + if size := GetEnvMaxUploadSize(); size != 100 { + t.Errorf("expected 100, got %d", size) + } + }) + + t.Run("Unparseable falls back to the default size and warns", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "not-a-number") + resetEnvWarnings(t) + captured := captureLog(t) + + if size := GetEnvMaxUploadSize(); size != defaultLimit { + t.Errorf("expected the default size %d, got %d", defaultLimit, size) + } + + logged := captured.String() + for _, want := range []string{"MAX_UPLOAD_SIZE", "not-a-number", "31457280"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } + } + }) + + t.Run("Above the hard cap returns the hard cap and warns", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "104857600") + resetEnvWarnings(t) + captured := captureLog(t) + + if size := GetEnvMaxUploadSize(); size != hardCapLimit { + t.Errorf("expected the hard cap %d, got %d", hardCapLimit, size) + } + + logged := captured.String() + for _, want := range []string{"MAX_UPLOAD_SIZE", "104857600", "52428800"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } + } + }) +} + +func TestGetEnvSentryDSN(t *testing.T) { + + t.Run("Unset returns empty string", func(t *testing.T) { + + unsetEnv(t, "SENTRY_DSN") + + if dsn := GetEnvSentryDSN(); dsn != "" { + t.Errorf("expected an empty DSN when SENTRY_DSN is unset, got %q", dsn) + } + }) + + t.Run("Set returns the DSN", func(t *testing.T) { + + const expected = "https://public@sentry.example.com/1" + t.Setenv("SENTRY_DSN", expected) + + if dsn := GetEnvSentryDSN(); dsn != expected { + t.Errorf("expected %q, got %q", expected, dsn) + } + }) +} diff --git a/shared/configs/setup.go b/shared/configs/setup.go index a10c4d3c..9e6dad35 100644 --- a/shared/configs/setup.go +++ b/shared/configs/setup.go @@ -3,7 +3,11 @@ package configs import ( "context" "database/sql" + "encoding/json" + "os" + "sort" "strconv" + "strings" "sync" "time" @@ -51,7 +55,8 @@ func GetCollection(collectionName string) *mongo.Collection { func GetOptionLimit(query *bson.M, c *gin.Context) (*options.FindOptionsBuilder, error) { var offset int64 = 0 var err error - limit := GetEnvLimit() + + var limit = GetEnvLimit() if c.Query("offset") != "" { offset, err = strconv.ParseInt(c.Query("offset"), 10, 64) @@ -92,18 +97,109 @@ func ConnectClubsDB() *sql.DB { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - db, err := sql.Open("pgx", GetClubsDBUri()) + // Skip Clubs DB initialization when the optional CLUBS_DB_URI is not configured. + uri := GetClubsDBUri() + if uri == "" { + log.Println("No CLUBS_DB_URI provided in env file. Skipping Clubs DB connection.") + return + } + + db, err := sql.Open("pgx", uri) if err != nil { log.Panic("Unable to connect to clubs database.") } - if err = db.PingContext(ctx); err != nil { - log.Panic("Unable to ping clubs database") + // ping the database + err = db.PingContext(ctx) + if err != nil { + log.Panic("Unable to ping database") + return } log.Printf("Connected to Clubs DB") + clubsDbInstance = db }) return clubsDbInstance } + +// make sure this file is in gitignore if changed +const SemestersJSONFilename = "semesters.json" + +func CreateSemestersJSON() error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + res := GetCollection("sections").Distinct(ctx, "academic_session.name", bson.D{}) + if err := res.Err(); err != nil { + return err + } + + var terms []string + if err := res.Decode(&terms); err != nil { + return err + } + log.Printf("Aggregated semesters from MongoDB") + + type term struct { + name string + year int + season string + } + + var parsedTerms []term + seen := make(map[string]struct{}) + + for _, str := range terms { + if len(str) < 3 { + continue + } + + str = strings.ToLower(strings.TrimSpace(str)) + + // Solution for possible duplicate value case (if database query returns '24F' and '24f') + if _, exists := seen[str]; exists { + continue + } + + year, err := strconv.Atoi(str[:2]) + if err != nil { + continue + } + parsedTerms = append(parsedTerms, term{ + name: str, + year: year, + season: str[2:], + }) + } + + seasonOrder := map[string]int{"f": 3, "u": 2, "s": 1} + + // Sort terms by recency + sort.Slice(parsedTerms, func(i, j int) bool { + if parsedTerms[i].year != parsedTerms[j].year { + return parsedTerms[i].year > parsedTerms[j].year + } + // Sort by season + return seasonOrder[parsedTerms[i].season] > seasonOrder[parsedTerms[j].season] + }) + + sortedTerms := make([]string, len(parsedTerms)) + for i, t := range parsedTerms { + sortedTerms[i] = t.name + } + + jsonData, err := json.Marshal(sortedTerms) + if err != nil { + return err + } + + err = os.WriteFile(SemestersJSONFilename, jsonData, 0644) + if err != nil { + return err + } + + log.Printf("Created semesters JSON file") + return nil +} diff --git a/shared/configs/setup_test.go b/shared/configs/setup_test.go index 277b8fed..55cba67a 100644 --- a/shared/configs/setup_test.go +++ b/shared/configs/setup_test.go @@ -19,8 +19,11 @@ func TestGetOptionLimit(t *testing.T) { query := bson.M{"offset": "should-be-ignored"} optionsBuilder, err := GetOptionLimit(&query, c) - options := buildOptions(optionsBuilder) + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + options, err := buildOptions(optionsBuilder) if err != nil { t.Fatalf("Expected no error, got %v", err) } @@ -36,7 +39,11 @@ func TestGetOptionLimit(t *testing.T) { query := bson.M{} optionsBuilder, _ := GetOptionLimit(&query, c) - options := buildOptions(optionsBuilder) + + options, err := buildOptions(optionsBuilder) + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } if options.Skip == nil || *options.Skip != int64(0) { t.Errorf("Expected default Skip to be 0, got %v", options.Skip) @@ -113,10 +120,12 @@ func isEqual(actual interface{}, expected int) bool { } } -func buildOptions(optionsBuilder *options.FindOptionsBuilder) options.FindOptions { - var options options.FindOptions +func buildOptions(optionsBuilder *options.FindOptionsBuilder) (options.FindOptions, error) { + var opts options.FindOptions for _, set := range optionsBuilder.Opts { - _ = set(&options) + if err := set(&opts); err != nil { + return options.FindOptions{}, err + } } - return options + return opts, nil }