Skip to content

Instantly share code, notes, and snippets.

Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@sneub
sneub / rolling_active_users.sql
Created June 24, 2021 09:57
BigQuery script to recreate the rolling active users chart data from Firebase and Google Analytics
WITH daily AS (
SELECT
PARSE_DATE("%Y%m%d", event_date) as date,
HLL_COUNT.init(user_id) users_sketch,
FROM `<your_GA_events_table>`
GROUP BY 1
),
month_day_window AS (
SELECT
date,
@sneub
sneub / resolvers.js
Created January 30, 2021 22:10
firebase-graphql-api resolvers v3
const firebase = require('firebase-admin');
const resolvers = {
Query: {
async hello(_, { name }) {
return `Hello ${name || 'World'}`;
},
async getTodos() {
const db = firebase.firestore();
@sneub
sneub / schema.js
Last active January 30, 2021 22:06
firebase-graphql-api schema.js v3
const typeDefs = `
type Query {
hello(name: String): String!
getTodos: [Todo]
}
type Mutation {
addTodo(text: String): String!
}
@sneub
sneub / resolvers.js
Created January 30, 2021 21:59
firebase-graphql-api resolvers v2
const firebase = require('firebase-admin');
const resolvers = {
Query: {
async hello(_, { name }) {
return `Hello ${name || 'World'}`;
},
},
Mutation: {
@sneub
sneub / index.js
Created January 30, 2021 21:58
firebase-graphql-api index v1
const functions = require('firebase-functions');
const firebase = require('firebase-admin');
let firebaseConfig = functions.config().firebase;
firebase.initializeApp(firebaseConfig);
const graphql = require('./graphql');
exports.graphql = functions.https.onRequest(graphql);
@sneub
sneub / graphql_index.js
Created January 30, 2021 21:57
firebase-graphql-api graphql/index
const { GraphQLServer } = require('graphql-yoga');
const typeDefs = require('./schema');
const resolvers = require('./resolvers');
const server = new GraphQLServer({
typeDefs,
resolvers,
introspection: true,
playground: true,
});
@sneub
sneub / resolvers.js
Created January 30, 2021 21:55
firebase-graphql-api resolvers v1
const firebase = require('firebase-admin');
const resolvers = {
Query: {
async hello(_, { name }) {
return `Hello ${name || 'World'}`;
},
},
};
@sneub
sneub / schema.js
Created January 30, 2021 21:53
firebase-graphql-api schema v2
const typeDefs = `
type Query {
hello(name: String): String!
}
type Mutation {
addTodo(text: String): String!
}
`;
@sneub
sneub / gist:1afd98fc5f804549f6b54f07802c5d4b
Created January 30, 2021 21:52
firebase-graphql-api schema v1
const typeDefs = `
type Query {
hello(name: String): String!
}
`;
module.exports = typeDefs;