mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 23:30:05 +02:00
62 lines
1007 B
JavaScript
62 lines
1007 B
JavaScript
const graphql = require('graphql');
|
|
|
|
const {
|
|
GraphQLID,
|
|
GraphQLSchema,
|
|
GraphQLObjectType,
|
|
GraphQLString
|
|
} = graphql;
|
|
|
|
const EventType = new GraphQLObjectType({
|
|
name: 'EventType',
|
|
fields: {
|
|
value: {
|
|
type: GraphQLString
|
|
},
|
|
when: {
|
|
type: GraphQLString
|
|
}
|
|
}
|
|
});
|
|
|
|
const EventSubscription = {
|
|
type: EventType,
|
|
args: {
|
|
container: {
|
|
type: GraphQLID
|
|
}
|
|
},
|
|
start: function() {
|
|
console.log('start', arguments);
|
|
},
|
|
stop: function() {
|
|
console.log('stop', arguments);
|
|
},
|
|
resolve: function() {
|
|
console.log('resolve', arguments);
|
|
}
|
|
};
|
|
|
|
const subscription = new GraphQLObjectType({
|
|
name: 'RootSubscriptionType',
|
|
fields: {
|
|
events: EventSubscription
|
|
}
|
|
});
|
|
|
|
module.exports = new GraphQLSchema({
|
|
query: new GraphQLObjectType({
|
|
name: 'Q',
|
|
fields: {
|
|
a: { type: GraphQLString },
|
|
}
|
|
}),
|
|
mutation: new GraphQLObjectType({
|
|
name: 'M',
|
|
fields: {
|
|
c: { type: GraphQLString },
|
|
}
|
|
}),
|
|
subscription
|
|
});
|