Skip to content

Conversation

@Anmol1696
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a 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 createGraphQLClient function 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-email function references from documentation and Docker Compose in favor of send-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.

Copy link
Contributor

Copilot AI left a 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;
Copy link

Copilot AI Jan 16, 2026

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.

Suggested change
headers.Host = hostHeader;
headers.host = hostHeader;

Copilot uses AI. Check for mistakes.
```

---
### Enqueue email_verification job
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
'sender_id', '$SENDER_ID'
)::json
);
"
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +180 to +186
apiExtensions: {
nodes: schemata
.split(',')
.map((schema) => schema.trim())
.map((schemaName) => ({ schemaName })),
},
schemaNames: { nodes: [] as Array<{ schemaName: string }> },
schemasByApiSchemaApiIdAndSchemaId: { nodes: [] as Array<{ schemaName: string }> },
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +214 to +217
apiExtensions: {
nodes: schemata.map((schemaName: string) => ({ schemaName })),
},
schemaNames: { nodes: [] as Array<{ schemaName: string }> },
schemasByApiSchemaApiIdAndSchemaId: { nodes: [] as Array<{ schemaName: string }> },
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +85
// 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.
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +102 to 114
// 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;
}
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
# 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
Copy link

Copilot AI Jan 16, 2026

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).

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants