Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
const generateConfig = await config!.getDefault().extension('generate');
// connect to db
const db = await connect(generateConfig.db.dbConfig);
const schema = makeExecutableSchema({
typeDefs,
resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false
}
});
const pubSub = new PubSub();
const context = createKnexRuntimeContext(db, pubSub);
const apolloConfig = {
schema,
context
}
const apolloServer = new ApolloServer(apolloConfig)
apolloServer.applyMiddleware({ app })
const httpServer = http.createServer(app)
apolloServer.installSubscriptionHandlers(httpServer)
httpServer.listen({ port: 4000 }, () => {
// tslint:disable-next-line: no-console
console.log(`🚀 Server ready at http://localhost:4000/graphql`)
END_POINT,
FE_URL,
GRAPHQL_DEPTH_LIMIT,
ACCESS_TOKEN
} from '@environments'
// const gateway = new ApolloGateway({
// serviceList: [
// { name: 'accounts', url: 'http://localhost:11041/graphql' },
// { name: 'reviews', url: 'http://localhost:11042/graphql' },
// { name: 'products', url: 'http://localhost:11043/graphql' },
// { name: 'inventory', url: 'http://localhost:11044/graphql' }
// ]
// })
const pubsub = new PubSub()
class MyErrorTrackingExtension extends GraphQLExtension {
willSendResponse(o) {
const { context, graphqlResponse } = o
context.trackErrors(graphqlResponse.errors)
return o
}
// Other lifecycle methods include
// requestDidStart
// parsingDidStart
// validationDidStart
// executionDidStart
// willSendResponse
}
it('should create a question when authenticated', async () => {
const user = await createRows.createUser()
const pubSub = new PubSub()
const context = getContext({ user, pubSub })
const variables = {
content: 'What does the fox say?',
}
const result = await graphql(schema, query, rootValue, context, variables)
expect(result).toMatchSnapshot()
})
import { PubSub } from 'graphql-subscriptions';
import { socket } from '../../server';
export const pubsub = new PubSub();
export const USER_CHANGED_TOPIC = 'user_change';
export const PIN_CHANGED_TOPIC = 'pin_change';
pubsub.subscribe(USER_CHANGED_TOPIC, (message) => socket.emit(USER_CHANGED_TOPIC, message));
pubsub.subscribe(PIN_CHANGED_TOPIC, (message) => socket.emit(PIN_CHANGED_TOPIC, message));
this.setContext(config.context);
delete config.context;
}
if (config.allows) {
_acl["default"].allow(config.allows);
this.acl = _acl["default"];
}
for (var _i = 0, _Object$keys = Object.keys(config); _i < _Object$keys.length; _i++) {
var key = _Object$keys[_i];
this[key] = config[key];
}
this.pubSub = new _graphqlSubscriptions.PubSub();
if (config.withApollo !== true) {
(0, _composer.createScalarType)("Upload");
(0, _composer.addResolver)("Upload", _UploadType["default"]);
}
}
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _graphqlSubscriptions = require('graphql-subscriptions');
exports.default = new _graphqlSubscriptions.PubSub();
import { PubSub } from 'graphql-subscriptions';
export const pubsub = new PubSub();
import { IFlightInfo } from '../../db';
import { KafkaFlightInfoProducer } from '../../kafka';
import { Airport } from '../../db/models/airport';
import { PubSub, withFilter } from 'graphql-subscriptions';
const producer = new KafkaFlightInfoProducer();
export const pubsub = new PubSub();
export const resolvers = {
Query: {
fetchAirports: async (_, { airportToSearch, airportId }) => {
const airports = await Airport.findAirports(airportToSearch, airportId);
return airports;
}
},
Mutation: {
sendFlightInfo: async (_, { flightInfo }) => {
producer.sendFlightInfo(flightInfo as IFlightInfo);
return flightInfo;
}
},
Subscription: {
getTweets: {
import { Inject } from '@nestjs/common';
import { MailService } from '../mail/mail.service';
import { Args, Mutation, Resolver, Subscription } from '@nestjs/graphql';
import { PubSub } from 'graphql-subscriptions';
import { Delivery } from './contact.model';
const pubSub = new PubSub();
@Resolver('Contact')
export class ContactResolvers {
constructor(@Inject('MailService') private mailService: MailService) {}
@Mutation('submitContactRequest')
submitContactRequest(@Args('name') name: string, @Args('email') email: string, @Args('message') message: string): Delivery {
this.mailService.sendEmail(name, email, 'GEOLUD-SITE: Contact Request', message);
pubSub.publish('contactRequestSubmitted', { contactRequestSubmitted: 'contact request sent' });
return {
sentAt: new Date(),
};
}
@Subscription('contactRequestSubmitted')
contactRequestSubmitted() {