allow circular dependencies in graphql
This commit is contained in:
parent
6bf401b3bb
commit
125ac9a167
@ -1,4 +1,3 @@
|
|||||||
const MachineType = require('../types/machine');
|
|
||||||
const api = require('../../api');
|
const api = require('../../api');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -36,7 +35,8 @@ const FirewallRuleSyntaxType = new GraphQLObjectType({
|
|||||||
|
|
||||||
module.exports = new GraphQLObjectType({
|
module.exports = new GraphQLObjectType({
|
||||||
name: 'FirewallRuleType',
|
name: 'FirewallRuleType',
|
||||||
fields: {
|
// function to allow circular dependencies
|
||||||
|
fields: () => ({
|
||||||
id: {
|
id: {
|
||||||
type: GraphQLID,
|
type: GraphQLID,
|
||||||
description: 'Unique identifier for this rule'
|
description: 'Unique identifier for this rule'
|
||||||
@ -79,7 +79,8 @@ module.exports = new GraphQLObjectType({
|
|||||||
description: 'Human-readable description for the rule'
|
description: 'Human-readable description for the rule'
|
||||||
},
|
},
|
||||||
machines: {
|
machines: {
|
||||||
type: new GraphQLList(MachineType),
|
// circular dependency
|
||||||
|
type: new GraphQLList(require('./machine')),
|
||||||
description: 'Lists all instances a firewall rule is applied to',
|
description: 'Lists all instances a firewall rule is applied to',
|
||||||
resolve: (root) => {
|
resolve: (root) => {
|
||||||
return api.firewallRules.listMachines({
|
return api.firewallRules.listMachines({
|
||||||
@ -87,5 +88,5 @@ module.exports = new GraphQLObjectType({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const FirewallRuleType = require('./firewall-rule');
|
|
||||||
const DynamicObjectType = require('./dynamic-object');
|
const DynamicObjectType = require('./dynamic-object');
|
||||||
const SnapshotType = require('./snapshot');
|
const SnapshotType = require('./snapshot');
|
||||||
const api = require('../../api');
|
const api = require('../../api');
|
||||||
@ -16,7 +15,8 @@ const {
|
|||||||
module.exports = new GraphQLObjectType({
|
module.exports = new GraphQLObjectType({
|
||||||
name: 'MachineType',
|
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',
|
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: {
|
id: {
|
||||||
type: GraphQLID,
|
type: GraphQLID,
|
||||||
description: 'Unique id for this instance'
|
description: 'Unique id for this instance'
|
||||||
@ -110,7 +110,8 @@ module.exports = new GraphQLObjectType({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
firewall_rules: {
|
firewall_rules: {
|
||||||
type: new GraphQLList(FirewallRuleType),
|
// circular dependency
|
||||||
|
type: new GraphQLList(require('./firewall-rule')),
|
||||||
description: 'List of FirewallRules affecting this machine',
|
description: 'List of FirewallRules affecting this machine',
|
||||||
resolve: (root) => {
|
resolve: (root) => {
|
||||||
return api.firewallRules.listByMachine(root.id);
|
return api.firewallRules.listByMachine(root.id);
|
||||||
@ -147,7 +148,7 @@ module.exports = new GraphQLObjectType({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports.locality = new GraphQLInputObjectType({
|
module.exports.locality = new GraphQLInputObjectType({
|
||||||
|
Loading…
Reference in New Issue
Block a user