Allow deserialization of multiple audiences from string with delimiter
#7986
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
- [x] PR description explains the motivation for the change and relevant context for reviewing
- [x] PR description links appropriate GitHub/Jira tickets (creating when necessary)
- [x] Changeset is included for user-facing changes
- [x] Changes are compatible[^1]
- [x] Documentation[^2] completed
- [x] Performance impact assessed and acceptable
- [x] Metrics and logs are added[^3] and documented
- Tests added and passing[^4]
- [x] Unit tests
- [ ] Integration tests (not necessary?)
- [x] Manual tests, as necessary
Exceptions
N/A
Notes
This pull request implements the feature proposed in:
Issue: Support delimited string for audiences to allow dynamic configuration via environment variables
(Submitted by me)
π§ Motivation
In dynamic environments like staging, QA, or production, we rely on injecting runtime configuration via environment variables rather than rebuilding Docker images. However, the current audiences configuration requires a YAML list, which cannot be passed directly as a string environment variable without complex workarounds.
This PR allows audiences to be configured as either:
- A list (status quo)
- A single string delimited by
;, e.g.,"aud1;aud2"
This enables clean runtime injection from variables like:
audiences: ${env.PROVIDER_AUDIENCES}
Where PROVIDER_AUDIENCES="aud1;aud2".
π§ Whatβs changed
- Added a custom
deserialize_audiencesfunction to allowaudiencesto be:- a single string (split on
;into multiple values) - or an array of strings (as currently supported)
- a single string (split on
- Added a
#[schemars(schema_with = "audiences_schema")]override to document this in the generated OpenAPI schema. - Added a test
deserializes_audiences_configurationcovering all supported YAML formats.
π Example config support
# Supported:
audiences: "aud1;aud2"
audiences:
- aud1
- aud2
# Not supported (still): JSON-like string list
audiences: "[\"aud1\", \"aud2\"]"
β Compatibility
This change is backward-compatible and non-breaking. Existing YAML lists continue to work as-is. This only enhances input flexibility.
Let me know if Apollo prefers a different delimiter than ; or would like this feature gated behind a flag.
[^1]: It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.
[^2]: Configuration is an important part of many changes. Where applicable please try to document configuration examples.
[^3]: A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.
[^4]: Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.
@StanlieK: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/
@dylan-apollo @abernix May I kindly request a review when you have a moment? Additionally, Iβm having trouble understanding the cause of the failing checks. Could you please assist? Thank you very much in advance!