Scrape Asset GraphQL Mutation

- Adds support for force scraping the asset via a GraphQL mutation.
This commit is contained in:
Wyatt Johnson
2018-03-05 11:53:52 -07:00
parent 8d147dbf47
commit a749a13786
3 changed files with 26 additions and 0 deletions
+14
View File
@@ -56,12 +56,25 @@ const closeNow = async (ctx, id) =>
}
);
/**
* scrapeAsset will force scrape an asset.
*
* @param {Object} ctx graphql context
* @param {String} id the asset's id to scrape
*/
const scrapeAsset = async (ctx, id) => {
const { services: { Scraper } } = ctx;
return Scraper.create({ id });
};
module.exports = ctx => {
let mutators = {
Asset: {
updateSettings: () => Promise.reject(errors.ErrNotAuthorized),
updateStatus: () => Promise.reject(errors.ErrNotAuthorized),
closeNow: () => Promise.reject(errors.ErrNotAuthorized),
scrape: () => Promise.reject(errors.ErrNotAuthorized),
},
};
@@ -75,6 +88,7 @@ module.exports = ctx => {
mutators.Asset.updateStatus = (id, status) =>
updateStatus(ctx, id, status);
mutators.Asset.closeNow = id => closeNow(ctx, id);
mutators.Asset.scrape = id => scrapeAsset(ctx, id);
}
}
+3
View File
@@ -133,6 +133,9 @@ const RootMutation = {
revokeToken: async (_, { input }, { mutators: { Token } }) => {
await Token.revoke(input);
},
forceScrapeAsset: async (_, { id }, { mutators: { Asset } }) => {
await Asset.scrape(id);
},
};
module.exports = RootMutation;
+9
View File
@@ -1395,6 +1395,12 @@ type SetUserRoleResponse implements Response {
errors: [UserError!]
}
type ForceScrapeAssetResponse implements Response {
# An array of errors relating to the mutation that occurred.
errors: [UserError!]
}
# All mutations for the application are defined on this object.
type RootMutation {
@@ -1489,6 +1495,9 @@ type RootMutation {
# Stop Ignoring comments by another user.
stopIgnoringUser(id: ID!): StopIgnoringUserResponse
# forceScrapeAsset will force scrape the Asset with the given ID.
forceScrapeAsset(id: ID!): ForceScrapeAssetResponse
}
type UsernameChangedPayload {