1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-10 21:30:06 +02:00

allow circular dependencies in graphql

This commit is contained in:
Sérgio Ramos 2016-10-25 20:34:56 +01:00
parent 6bf401b3bb
commit 125ac9a167
2 changed files with 10 additions and 8 deletions

View File

@ -1,4 +1,3 @@
const MachineType = require('../types/machine');
const api = require('../../api');
const {
@ -36,7 +35,8 @@ const FirewallRuleSyntaxType = new GraphQLObjectType({
module.exports = new GraphQLObjectType({
name: 'FirewallRuleType',
fields: {
// function to allow circular dependencies
fields: () => ({
id: {
type: GraphQLID,
description: 'Unique identifier for this rule'
@ -79,7 +79,8 @@ module.exports = new GraphQLObjectType({
description: 'Human-readable description for the rule'
},
machines: {
type: new GraphQLList(MachineType),
// circular dependency
type: new GraphQLList(require('./machine')),
description: 'Lists all instances a firewall rule is applied to',
resolve: (root) => {
return api.firewallRules.listMachines({
@ -87,5 +88,5 @@ module.exports = new GraphQLObjectType({
});
}
}
}
})
});

View File

@ -1,4 +1,3 @@
const FirewallRuleType = require('./firewall-rule');
const DynamicObjectType = require('./dynamic-object');
const SnapshotType = require('./snapshot');
const api = require('../../api');
@ -16,7 +15,8 @@ const {
module.exports = new GraphQLObjectType({
name: 'MachineType',
description: 'An image contains the software packages that will be available on newly-provisioned instance. In the case of hardware virtual machines, the image also includes the operating system',
fields: {
// function to allow circular dependencies
fields: () => ({
id: {
type: GraphQLID,
description: 'Unique id for this instance'
@ -110,7 +110,8 @@ module.exports = new GraphQLObjectType({
}
},
firewall_rules: {
type: new GraphQLList(FirewallRuleType),
// circular dependency
type: new GraphQLList(require('./firewall-rule')),
description: 'List of FirewallRules affecting this machine',
resolve: (root) => {
return api.firewallRules.listByMachine(root.id);
@ -147,7 +148,7 @@ module.exports = new GraphQLObjectType({
});
}
}
}
})
});
module.exports.locality = new GraphQLInputObjectType({