Skip to content

Instantly share code, notes, and snippets.

View ronalddddd's full-sized avatar
👋
Hi

Ronald Ng ronalddddd

👋
Hi
View GitHub Profile
@epalaz
epalaz / resolvers.js
Last active April 28, 2020 15:16
Resolvers for File Upload Mutations
const resolvers = {
Mutation: {
singleUpload: (parent, args) => {
return args.file.then(file => {
const {createReadStream, filename, mimetype} = file
const fileStream = createReadStream()
fileStream.pipe(fs.createWriteStream(`./uploadedFiles/${filename}`))
@josephktcheung
josephktcheung / index.ts
Last active November 3, 2022 02:19
Stitching schema with subscription
import { GraphQLServer, Options } from 'graphql-yoga'
import { mergeSchemas } from 'graphql-tools';
import { getRemoteSchema } from "./remoteSchema";
import { SubscriptionClient } from 'subscriptions-transport-ws';
import * as ws from 'ws';
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
@eliotsykes
eliotsykes / ngFocusAndBlur.js
Created April 16, 2013 09:27
AngularJS ngFocus and ngBlur directives - one way to get them before they get released. Before using, consider re-naming ngFocus and ngBlur to something that doesn't invade the ng namespace, e.g. replace all 'ngFocus' and 'ngBlur' strings with 'ngcFocus' and 'ngcBlur' (where c = cats/custom).
app.directive('ngFocus', ['$parse', function($parse) {
return function(scope, element, attr) {
var fn = $parse(attr['ngFocus']);
element.bind('focus', function(event) {
scope.$apply(function() {
fn(scope, {$event:event});
});
});
}
}]);