Skip to content

Commit

Permalink
Enable AWS X-Ray on AppSync APIs (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
yai333 committed Mar 20, 2020
1 parent 755f07d commit b4edb3f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions __snapshots__/get-config.test.js.snap
Expand Up @@ -88,6 +88,7 @@ schema {
"substitutions": Object {},
"tags": undefined,
"userPoolConfig": undefined,
"xrayEnabled": false,
},
]
`;
Expand Down Expand Up @@ -207,6 +208,7 @@ schema {
"substitutions": Object {},
"tags": undefined,
"userPoolConfig": undefined,
"xrayEnabled": false,
},
]
`;
Expand Down Expand Up @@ -339,6 +341,7 @@ schema {
"substitutions": Object {},
"tags": undefined,
"userPoolConfig": undefined,
"xrayEnabled": false,
},
]
`;
Expand Down Expand Up @@ -475,6 +478,7 @@ schema {
"substitutions": Object {},
"tags": undefined,
"userPoolConfig": undefined,
"xrayEnabled": false,
},
]
`;
Expand Down Expand Up @@ -603,6 +607,7 @@ schema {
"substitutions": Object {},
"tags": undefined,
"userPoolConfig": undefined,
"xrayEnabled": false,
},
]
`;
9 changes: 9 additions & 0 deletions index.test.js
Expand Up @@ -35,6 +35,7 @@ beforeEach(() => {
isSingleConfig: true,
mappingTemplatesLocation: 'mapping-templates',
substitutions: {},
xrayEnabled: false,
};
});

Expand Down Expand Up @@ -236,6 +237,14 @@ describe('appsync config', () => {
});
});

test('xrayEnabled config created', () => {
const resources = plugin.getGraphQlApiEndpointResource({
...config,
xrayEnabled: true,
});
expect(resources.GraphQlApi.Properties.XrayEnabled).toEqual(true);
});

test('Tags config created', () => {
const resources = plugin.getGraphQlApiEndpointResource({
...config,
Expand Down
4 changes: 4 additions & 0 deletions src/get-config.js
Expand Up @@ -34,6 +34,9 @@ const getConfig = (config, provider, servicePath) => {
if (config.substitutions && typeof config.substitutions !== 'object') {
throw new Error('substitutions property must be an object');
}
if (config.xrayEnabled && typeof config.xrayEnabled !== 'boolean') {
throw new Error('xrayEnabled must be a boolean');
}

const mappingTemplatesLocation = config.mappingTemplatesLocation || 'mapping-templates';
const functionConfigurationsLocation = config.functionConfigurationsLocation
Expand Down Expand Up @@ -84,6 +87,7 @@ const getConfig = (config, provider, servicePath) => {
functionConfigurations,
logConfig: config.logConfig,
substitutions: config.substitutions || {},
xrayEnabled: config.xrayEnabled || false,
tags: config.tags,
};
};
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -381,6 +381,7 @@ class ServerlessAppsyncPlugin {
FieldLogLevel: config.logConfig.level,
ExcludeVerboseContent: config.logConfig.excludeVerboseContent,
},
XrayEnabled: config.xrayEnabled,
Tags: !config.tags ? undefined : this.getTagsConfig(config),
},
},
Expand Down

0 comments on commit b4edb3f

Please sign in to comment.