-
Notifications
You must be signed in to change notification settings - Fork 5
WIP: feature: update function to use admin server with headers #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the send-email-link Knative function to support header-based routing for GraphQL requests to an admin server with API_IS_PUBLIC=false. The changes enable multi-tenant GraphQL access using custom headers (X-Database-Id, X-Meta-Schema, X-Api-Name, X-Schemata) instead of relying on hostname-based routing.
Changes:
- Enhanced
createGraphQLClientfunction to support additional header-based routing options for internal admin server communication - Updated Docker Compose configuration to use the new admin server setup with
API_IS_PUBLIC=false - Replaced outdated PostgreSQL image with newer version (
ghcr.io/constructive-io/docker/postgres-plus:17) - Removed
simple-emailfunction references from documentation and Docker Compose in favor ofsend-email-link
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
jobs/README.md |
Updated documentation to reflect send-email-link function usage with admin server header-based routing, removed simple-email references |
functions/send-email-link/src/index.ts |
Refactored createGraphQLClient to accept an options object with header-based routing parameters (databaseId, useMetaSchema, apiName, schemata) |
docker-compose.yml |
Updated PostgreSQL image from pyramation/pgvector:13.3-alpine to ghcr.io/constructive-io/docker/postgres-plus:17 |
docker-compose.jobs.yml |
Renamed service from constructive-server to constructive-admin-server, added API_IS_PUBLIC=false, removed simple-email service references |
Comments suppressed due to low confidence (1)
jobs/README.md:1
- Corrected malformed heading. There's an extra 'n' character before the '#' symbol.
n# Jobs (Knative)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (1)
jobs/README.md:2
- The line marker '----' (line 0 in diff) should be '---' (three hyphens) to match standard Markdown horizontal rule syntax used elsewhere in the document.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const hostHeader = process.env[envName]; | ||
| if (hostHeader) { | ||
| headers.host = hostHeader; | ||
| headers.Host = hostHeader; |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP header names should be lowercase when setting them programmatically. The graphql-request library expects lowercase header names. Change 'Host' to 'host' to ensure proper header transmission.
| headers.Host = hostHeader; | |
| headers.host = hostHeader; |
| ``` | ||
|
|
||
| --- | ||
| ### Enqueue email_verification job |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line marker '----' (line 0 in diff) should be '---' (three hyphens) to match standard Markdown horizontal rule syntax used elsewhere in the document.
| 'sender_id', '$SENDER_ID' | ||
| )::json | ||
| ); | ||
| " |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line marker '----' (line 0 in diff) should be '---' (three hyphens) to match standard Markdown horizontal rule syntax used elsewhere in the document.
| apiExtensions: { | ||
| nodes: schemata | ||
| .split(',') | ||
| .map((schema) => schema.trim()) | ||
| .map((schemaName) => ({ schemaName })), | ||
| }, | ||
| schemaNames: { nodes: [] as Array<{ schemaName: string }> }, | ||
| schemasByApiSchemaApiIdAndSchemaId: { nodes: [] as Array<{ schemaName: string }> }, |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renamed field structure (apiExtensions and schemasByApiSchemaApiIdAndSchemaId) for hardcoded schemata routing lacks test coverage. Consider adding tests to verify the restructured data format works correctly with transformServiceToApi.
| apiExtensions: { | ||
| nodes: schemata.map((schemaName: string) => ({ schemaName })), | ||
| }, | ||
| schemaNames: { nodes: [] as Array<{ schemaName: string }> }, | ||
| schemasByApiSchemaApiIdAndSchemaId: { nodes: [] as Array<{ schemaName: string }> }, |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renamed field structure for meta schema routing lacks test coverage. Consider adding tests to verify this data structure works correctly with transformServiceToApi.
| // TODO: Consider moving this to @constructive-io/knative-job-fn as a shared | ||
| // utility so all job functions can create GraphQL clients with consistent | ||
| // header-based routing without duplicating this logic. |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment identifies important refactoring work to share GraphQL client creation logic across job functions. Consider creating a tracking issue or documenting this technical debt in a more visible location to ensure it's addressed before this PR is finalized.
| // Header-based routing for internal cluster services (API_IS_PUBLIC=false) | ||
| if (options.databaseId) { | ||
| headers['X-Database-Id'] = options.databaseId; | ||
| } | ||
| if (options.useMetaSchema) { | ||
| headers['X-Meta-Schema'] = 'true'; | ||
| } | ||
| if (options.apiName) { | ||
| headers['X-Api-Name'] = options.apiName; | ||
| } | ||
| if (options.schemata) { | ||
| headers['X-Schemata'] = options.schemata; | ||
| } |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new header-based routing logic with multiple conditional header additions lacks test coverage. Consider adding unit tests to verify correct header construction for different option combinations.
| # Point to admin server (uses X-Api-Name header routing when API_IS_PUBLIC=false) | ||
| GRAPHQL_URL: "http://constructive-admin-server:3000/graphql" | ||
| META_GRAPHQL_URL: "http://constructive-admin-server:3000/graphql" | ||
| # API name for header-based routing (X-Api-Name header) - kept for future use |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states 'kept for future use' but GRAPHQL_API_NAME is set to 'private'. This is confusing - either the variable is currently used (in which case update the comment) or it's not needed yet (in which case consider removing it until actually required).
| # API name for header-based routing (X-Api-Name header) - kept for future use | |
| # API name for header-based routing (X-Api-Name header), e.g. when API_IS_PUBLIC=false |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.