Skip to content

Commit

Permalink
updates from code review including Shop ID and array map
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Potter <chris@reactioncommerce.com>
  • Loading branch information
Chris Potter committed Apr 9, 2019
1 parent dc4e8e0 commit dc63918
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import packageJson from "/package.json";
import ReactionError from "@reactioncommerce/reaction-error";


/**
* @name queries.systemInformation
* @method
* @memberof SystemInformation/GraphQL
* @summary get systemInformations
* @param {String} args.shopId The ID of the shop to load settings for
* @param {Object} context - an object containing the per-request state
* @return {<Object} System Information
**/
export default async function systemInformation(context) {
export default async function systemInformation(id, context) {
if (!context.userHasPermission(["owner", "admin"], id)) throw new ReactionError("access-denied", "User does not have permission");
const plugins = await context.collections.Packages.find({ shopId: id, version: { $exists: true } }).toArray();
return {
apiVersion: packageJson.version,
plugins: await context.collections.Packages.find({ version: { $exists: true } }).toArray()
plugins: plugins.map(({ name, version }) => ({ name, version }))
};
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { decodeShopOpaqueId } from "@reactioncommerce/reaction-graphql-xforms/shop";

/**
* @name Query.systemInformation
* @method
* @memberof SystemInformation/GraphQL
* @summary get system information for reaction site
* @param {ConnectionArgs} args An object of all arguments that were sent by the client
* @param {String} args.shopId The ID of the shop to load navigation items for
* @param {Object} context An object containing the per-request state
* @return {<Object>} System Information Object
*/
export default async function systemInformation(_, args, context) {
return context.queries.systemInformation(context);
const dbShopId = decodeShopOpaqueId(args.shopId);
return context.queries.systemInformation(dbShopId, context);
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
extend type Query {
systemInformation: SystemInfo
systemInformation(shopId: ID!): SystemInformation!
}

"Represents Reaction Plugin"
type Plugin {
name: String,
# name of plugin
name: String
# version of plugin
version: String
}

"Represents Reaction System Infomation"
type SystemInfo {
type SystemInformation {
# core api version
apiVersion: String,
apiVersion: String
# TODO: data version
# TODO: mongo version
#plugins installed with name, version information
plugins:[Plugin]
}

0 comments on commit dc63918

Please sign in to comment.