New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloudapi-gql

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudapi-gql - npm Package Compare versions

Comparing version 7.1.1 to 7.1.2

2

dev-server.js

@@ -34,3 +34,3 @@ 'use strict';

credentials: true,
additionalHeaders: ['Cookie']
additionalHeaders: ['Cookie', 'X-CSRF-Token']
}

@@ -37,0 +37,0 @@ },

@@ -103,2 +103,7 @@ 'use strict';

try {
if (method.toLowerCase() === 'head') {
const res = await this._wreck.request('head', path, wreckOptions);
return { res, payload: {} };
}
const results = await this._wreck[method](path, wreckOptions);

@@ -105,0 +110,0 @@ this._setCache(method, path, wreckOptions, results);

@@ -5,3 +5,3 @@ 'use strict';

const Utils = require('../utils');
const Formatters = () => require('../formatters'); // circular dep
const Formatters = () => { return require('../formatters'); }; // circular dep

@@ -8,0 +8,0 @@ // eslint-disable-next-line camelcase

@@ -41,3 +41,15 @@ 'use strict';

const { res: { headers } } = await fetch('/machines', {
method: 'head',
includeRes: true,
query: {
...query,
limit: null, // NOTE: no support for > 1000 instances
offset: null
}
});
const { res, payload } = await fetch('/machines', { query, includeRes: true });
res.headers['x-resource-count'] = headers['x-resource-count'];
return Utils.toPage({ payload, res, ...args });

@@ -44,0 +56,0 @@ };

@@ -8,3 +8,2 @@ 'use strict';

const Graphi = require('graphi');
const { makeExecutableSchema } = require('./utils');
const Package = require('../package.json');

@@ -51,4 +50,4 @@ const CloudApi = require('./cloudapi');

const schema = makeExecutableSchema({
typeDefs: Schema.toString(),
const schema = Graphi.makeExecutableSchema({
schema: Schema.toString(),
resolvers: Formatters

@@ -55,0 +54,0 @@ });

'use strict';
const Assert = require('assert');
const ForceArray = require('force-array');
const { graphql } = require('graphi');
const Hasha = require('hasha');

@@ -41,46 +39,1 @@

};
// Inspired by graphql-tools
exports.makeExecutableSchema = ({ typeDefs, resolvers = {} }) => {
const parsed = graphql.parse(typeDefs);
const astSchema = graphql.buildASTSchema(parsed, { commentDescriptions: true });
for (const resolverName of Object.keys(resolvers)) {
const type = astSchema.getType(resolverName);
Assert(type || resolverName === '__schema', `Missing schema definition for resolver: ${resolverName}`);
const typeResolver = resolvers[resolverName];
// go through field resolvers for the parent resolver type
for (const fieldName of Object.keys(typeResolver)) {
const fieldResolver = typeResolver[fieldName];
Assert(typeof fieldResolver === 'function', `${resolverName}.${fieldName} resolver must be a function`);
if (type instanceof graphql.GraphQLScalarType) {
type[fieldName] = fieldResolver;
continue;
}
if (type instanceof graphql.GraphQLEnumType) {
const fieldType = type.getValue(fieldName);
Assert(fieldType, `${resolverName}.${fieldName} enum definition missing from schema`);
fieldType.value = fieldResolver;
continue;
}
// no need to set resolvers unless we are dealing with a type that needs resolvers
if (!(type instanceof graphql.GraphQLObjectType) && !(type instanceof graphql.GraphQLInterfaceType)) {
continue;
}
const fields = type.getFields();
if (!fields) {
continue;
}
fields[fieldName].resolve = fieldResolver;
}
}
return astSchema;
};
{
"name": "cloudapi-gql",
"version": "7.1.1",
"version": "7.1.2",
"license": "MPL-2.0",

@@ -22,3 +22,3 @@ "repository": "github:joyent/cloudapi-gql",

"force-array": "3.1.x",
"fwrule": "1.4.x",
"fwrule": "2.x.x",
"graphi": "5.x.x",

@@ -25,0 +25,0 @@ "hasha": "3.0.x",

@@ -70,5 +70,5 @@ 'use strict';

const server = new Hapi.Server();
StandIn.replaceOnce(CloudApi.prototype, 'fetch', (stand) => {
StandIn.replace(CloudApi.prototype, 'fetch', (stand) => {
return { payload: [machine], res: { headers: { 'x-resource-count': 10 }} };
});
}, { stopAfter: 2 });

@@ -92,5 +92,9 @@ await server.register(register);

const server = new Hapi.Server();
StandIn.replaceOnce(CloudApi.prototype, 'fetch', (stand) => {
StandIn.replace(CloudApi.prototype, 'fetch', (stand) => {
if (stand.invocations === 1) {
return { payload: [machine, machine], res: { headers: { 'x-resource-count': 20 }} };
}
return { payload: [machine, machine], res: { headers: { 'x-resource-count': 10 }} };
});
}, { stopAfter: 2 });

@@ -105,3 +109,3 @@ await server.register(register);

expect(res.statusCode).to.equal(200);
expect(res.result.data.machines.total).to.equal(10);
expect(res.result.data.machines.total).to.equal(20);
expect(res.result.data.machines.offset).to.equal(1);

@@ -108,0 +112,0 @@ expect(res.result.data.machines.limit).to.equal(2);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc