package
0.0.0-20250308170929-48bd8ed27534
Repository: https://github.com/evergreen-ci/evergreen.git
Documentation: pkg.go.dev

# README

GraphQL Developer Guide

Modifying the GraphQL Schema

Fields

Add fields to .graphql files in the schema/ folder. When you run make gqlgen, these changes will be processed and a resolver will be generated.

You can also add models in gqlgen.yml. If a GraphQL object has a corresponding model definition in gqlgen.yml, then a resolver will not be generated. Instead you may have to edit the API models which are located in the rest/model/ folder.

Directives

Directives control access to certain mutations and queries. They are defined in schema/directives.graphql but their corresponding functions are not generated through make gqlgen. You will have to manually add or edit the directive functions in resolver.go.

Best Practices for GraphQL

Designing Mutations

When designing mutations, the input and payload should be objects. We often have to add new fields, and it is much easier to add backwards compatible changes if the existing fields are nested within an object.

In practice, this means you should prefer

  abortTask(opts: AbortTaskInput!): AbortTaskPayload

  AbortTaskInput {
    taskId: String!
  }

  AbortTaskPayload {
    task: Task
  }

over

abortTask(taskId: String!): Task

See the Apollo GraphQL blogpost from which this was referenced.

Note that this guideline only applies to mutations, not queries.

Nullability

Nullability is controlled via the exclamation mark (!). If you put an exclamation mark on a field, it means that the field cannot be null.

In general, you can reference this guide for nullability. Some callouts from this guide:

  • Complex objects should be nullable due to the "bubbling up" effect.
  • Lists should be non-nullable, and items contained within lists should be non-nullable.
  • Booleans should be non-nullable. If you have a third state to represent, consider using an enum. You may also want to consider if the boolean field has the potential to evolve into an enum, such as in the example described here.

These principles apply generally, but you may encounter situations where you'll want to deviate from these rules. Think carefully about marking fields as non-nullable, because if we query for a non-nullable field and get null as a response it will break parts of the application.

Writing GraphQL tests

You can add tests to the tests/ directory. The folder is structured as the following:

.
├── ...
├── resolver/ # Folder representing a resolver, e.g. query
│ ├── field/ # Folder representing a field on a resolver, e.g. mainlineCommits
│ ├──── queries/ # Folder containing query files (.graphql)
│ ├──── data.json # Data for tests in this directory
│ └──── results.json # Results for tests in this directory
└── ...

The tests run via the test runner defined in integration_atomic_test_util.go. If you see some behavior in your tests that can't be explained by what you've added, it's a good idea to check the setup functions defined in this file.

Note: Tests for directives are located in directive_test.go.

Specifying User to Run GraphQL Test

The GraphQL schema restricts access to certain queries and mutations based on a user's permissions. In order to test that these restrictions are working properly, you may want to run a GraphQL test as a particular user.

There are three users available by default:

  • admin_user: A superuser with admin project and distro access.
  • privileged_user: Not a superuser, but has admin project and distro access.
  • regular_user: Only has basic project and distro access.

Note that you can also create other users in the corresponding data.json file if none of these users work for your test.

To run a test as a particular user, specify the test_user_id field in the corresponding results.json file. If this field is not included, it will default to admin_user.

Running GraphQL tests

Before running any tests, ensure you have a creds.yml file set up. If you don't have it, you can create one by running the following command:

bash scripts/setup-credentials.sh

To run all of the tests, you can use the following command:

SETTINGS_OVERRIDE=creds.yml make test-service-graphql

To run a specific test, you can use the following command:

SETTINGS_OVERRIDE=creds.yml make test-service-graphql RUN_TEST=TestAtomicGQLQueries/<TestName>

# Functions

GenerateSecretFields generates a file that contains a list of fields that should be redacted in logs.
Handler returns a gimlet http handler func used as the gql route handler.
No description provided by the author
MarshalStringMap handles marshaling StringMap.
No description provided by the author
NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
RedactFieldsInMap recursively searches for and redacts fields in a map.
UnmarshalStringMap handles unmarshaling StringMap.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Forbidden conveys that user does not required permissions to access resource.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InputValidationError conveys that the given input is not formatted properly.
InternalServerError conveys that the server errored out when trying to perform an action.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PartialError conveys that the request succeeded, but there were nonfatal errors that may be communicated to users.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ResourceNotFound conveys the requested resource does not exist.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
Build Baron is a service that can be integrated into a project (see Confluence Wiki for more details).
BuildVariantOptions is an input to the mainlineCommits query.
No description provided by the author
No description provided by the author
CreateDistroInput is the input to the createDistro mutation.
DeactivateStepbackTaskInput is the input to the deactivateStepbackTask mutation.
DefaultSectionToRepoInput is the input to the defaultSectionToRepo mutation.
DeleteDistroInput is the input to the deleteDistro mutation.
Return type representing whether a distro was deleted.
DeleteGithubAppCredentialsInput is the input to the deleteGithubAppCredentials mutation.
DeleteGithubAppCredentialsPayload is returned by the deleteGithubAppCredentials mutation.
No description provided by the author
No description provided by the author
DisableQuery will return SERVICE_UNAVAILABLE for any query with an operation name listed in config.DisabledGQLQueries.
No description provided by the author
No description provided by the author
DistroEventsInput is the input to the distroEvents query.
No description provided by the author
No description provided by the author
No description provided by the author
EditSpawnHostInput is the input to the editSpawnHost mutation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GroupedProjects is the return value for the projects & viewableProjectRefs queries.
HostEvents is the return value for the hostEvents query.
No description provided by the author
HostsResponse is the return value for the hosts query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MainlineCommits is returned by the mainline commits query.
MainlineCommitsOptions is an input to the mainlineCommits query.
No description provided by the author
No description provided by the author
MoveProjectInput is the input to the attachProjectToNewRepo mutation.
No description provided by the author
Return type representing whether a distro was created and any validation errors.
PatchConfigure is the input to the schedulePatch mutation.
No description provided by the author
Patches is the return value of the patches field for the User and Project types.
PatchesInput is the input value to the patches field for the User and Project types.
No description provided by the author
No description provided by the author
No description provided by the author
PodEvents is the return value for the events query.
No description provided by the author
ProjectEvents contains project event log entries that concern the history of changes related to project settings.
No description provided by the author
No description provided by the author
PromoteVarsToRepoInput is the input to the promoteVarsToRepo mutation.
PublicKeyInput is an input to the createPublicKey and updatePublicKey mutations.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SaveDistroInput is the input to the saveDistro mutation.
Return type representing the updated distro and the number of hosts that were updated.
SetLastRevisionInput is the input to the setLastRevision mutation.
No description provided by the author
SortOrder[] is an input value for version.tasks.
SpawnHostInput is the input to the spawnHost mutation.
SpawnVolumeInput is the input to the spawnVolume mutation.
SplunkTracing is a graphql extension that adds splunk logging to graphql.
No description provided by the author
TaskFiles is the return value for the taskFiles query.
TaskFilterOptions defines the parameters that are used when fetching tasks from a Version.
TaskLogs is the return value for the task.taskLogs query.
TaskQueueDistro[] is the return value for the taskQueueDistros query.
TaskTestResult is the return value for the task.Tests resolver.
TaskTestResultSample is the return value for the taskTestSample query.
TestFilter is an input value for the taskTestSample query.
TestFilterOptions is an input for the task.Tests query.
TestSortOptions is an input for the task.Tests query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
UpdateVolumeInput is the input to the updateVolume mutation.
No description provided by the author
UserConfig is returned by the userConfig query.
No description provided by the author
No description provided by the author
No description provided by the author
VolumeHost is the input to the attachVolumeToHost mutation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GqlError represents the error codes send alongside gql errors.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author