Skip to content

fix: Updated index.mjs file to be modified for Apollo subgraph Federation 2 features #126

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

Merged
merged 4 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,6 @@ permissions and limitations under the License.
an input
schema ([#118](https://github.com/aws/amazon-neptune-for-graphql/pull/118))
* Fixed duplicated nodes and edges from nodes with
multi-labels ([#125](https://github.com/aws/amazon-neptune-for-graphql/pull/125))
multi-labels ([#125](https://github.com/aws/amazon-neptune-for-graphql/pull/125))
* Updated Apollo subgraph to allow use of Federation 2 features.
features ([#126](https://github.com/aws/amazon-neptune-for-graphql/pull/126))
2 changes: 1 addition & 1 deletion src/zipPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function createZip({targetZipFilePath, includePaths = [], includeContent =
output.on('close', () => resolve());
archive.on('error', err => reject(err));
});

archive.pipe(output);

includePaths.forEach(includePath => {
Expand Down
10 changes: 9 additions & 1 deletion templates/ApolloServer/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import dotenv from 'dotenv';

dotenv.config();

const typeDefs = parse(readFileSync('./output.schema.graphql', 'utf-8'));
const fileContent = readFileSync('./output.schema.graphql', 'utf-8');
let schema = fileContent;
if (process.env.SUBGRAPH === 'true') {
schema = `extend schema @link(
url: "https://specs.apollo.dev/federation/v2.0"
import: ["@key", "@shareable"]
)${fileContent}`;
}
const typeDefs = parse(schema);
const queryDefinition = typeDefs.definitions.find(
definition => definition.kind === 'ObjectTypeDefinition' && definition.name.value === 'Query'
);
Expand Down
3 changes: 3 additions & 0 deletions test/testLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ async function testApolloArtifacts(outputFolderPath, testDbInfo, subgraph = fals
];
const actualEnvContent = fs.readFileSync(path.join(outputFolderPath, 'unzipped', '.env'), 'utf8');
expect(actualEnvContent).toEqual(expectedEnvContent.join('\n'));

const actualIndexContent = fs.readFileSync(path.join(outputFolderPath, 'unzipped', 'index.mjs'), 'utf8');
expect(actualIndexContent).toContain('https://specs.apollo.dev/federation/v2.0');
});
}

Expand Down