Skip to content

Commit a165707

Browse files
committed
Updated index.mjs file to be modified for Apollo subgraph Federation 2 features
1 parent 6408f4e commit a165707

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ permissions and limitations under the License.
116116
option ([#117](https://github.com/aws/amazon-neptune-for-graphql/pull/117))
117117
* Fixed invalid schema generation when AWS AppSync scalar types are used in
118118
an input
119-
schema ([#118](https://github.com/aws/amazon-neptune-for-graphql/pull/118))
119+
schema ([#118](https://github.com/aws/amazon-neptune-for-graphql/pull/118))
120+
* Updated index.mjs file to be modified for Apollo subgraph Federation 2
121+
features ([#126](https://github.com/aws/amazon-neptune-for-graphql/pull/126))

src/zipPackage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function createZip({targetZipFilePath, includePaths = [], includeContent =
4949
output.on('close', () => resolve());
5050
archive.on('error', err => reject(err));
5151
});
52-
52+
5353
archive.pipe(output);
5454

5555
includePaths.forEach(includePath => {

templates/ApolloServer/index.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ import dotenv from 'dotenv';
88

99
dotenv.config();
1010

11-
const typeDefs = parse(readFileSync('./output.schema.graphql', 'utf-8'));
11+
const fileContent = readFileSync('./output.schema.graphql', 'utf-8');
12+
let schema = fileContent;
13+
if (process.env.SUBGRAPH === 'true') {
14+
schema = `extend schema @link(
15+
url: "https://specs.apollo.dev/federation/v2.0"
16+
import: ["@key", "@shareable"]
17+
)${fileContent}`;
18+
}
19+
const typeDefs = parse(schema);
1220
const queryDefinition = typeDefs.definitions.find(
1321
definition => definition.kind === 'ObjectTypeDefinition' && definition.name.value === 'Query'
1422
);

test/testLib.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ async function testApolloArtifacts(outputFolderPath, testDbInfo, subgraph = fals
226226
];
227227
const actualEnvContent = fs.readFileSync(path.join(outputFolderPath, 'unzipped', '.env'), 'utf8');
228228
expect(actualEnvContent).toEqual(expectedEnvContent.join('\n'));
229+
230+
const actualIndexContent = fs.readFileSync(path.join(outputFolderPath, 'unzipped', 'index.mjs'), 'utf8');
231+
expect(actualIndexContent).toContain('https://specs.apollo.dev/federation/v2.0');
229232
});
230233
}
231234

0 commit comments

Comments
 (0)