Skip to content

Instantly share code, notes, and snippets.

View RWaltersMA's full-sized avatar

Rob Walters RWaltersMA

View GitHub Profile
@RWaltersMA
RWaltersMA / connector.graphql
Created March 17, 2025 22:21
Complete Apollo Connector code for AWS Lambda Connector tutorial blog
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.10"
import: ["@key"]
)
@link(
url: "https://specs.apollo.dev/connect/v0.1"
import: ["@source", "@connect"]
)
@RWaltersMA
RWaltersMA / product-price.mjs
Created March 6, 2025 15:34
AWS Lambda function "product-price" for use in "Orchestrating AWS Lambda and DynamoDB Resources with Apollo Connectors" article
export const handler = async (event) => {
const id = event.product_id;
const products = [
{
id: "RANQi6AZkUXCbZ",
price: {
default_price: 49900,
is_active: true,
currency: "usd",
billing_schema: "per_unit",
@RWaltersMA
RWaltersMA / products.mjs
Created March 6, 2025 15:25
AWS Lambda function that returns product list for use in "Orchestrating AWS Lambda and DynamoDB Resources with Apollo Connectors" article
export const handler = async (event) => {
const products = [
{
"id": "RANQi6AZkUXCbZ",
"name": "OG Olive Putter - Blade",
"description": "The traditional Block in a blade shape is made from a solid block of Olive wood. The head weight is approximately 360 grams with the addition of pure tungsten weights. Paired with a walnut center-line and white accents colors.",
"image": "https://keynote-strapi-production.up.railway.app/uploads/thumbnail_IMG_9102_3119483fac.png"
},
{
"id": "RANYrWRy876AA5",
@RWaltersMA
RWaltersMA / stream.js
Created December 7, 2023 14:12
Atlas Stream Processing Solar Stream Sample Example
SAMPLE STREAM SOLAR
//Create the Stream Processor and add the sample_stream_solar connection registry connection first
//Create variablre for source connection
solar={$source:{connectionName:'sample_stream_solar', timeField: { $dateFromString: { dateString: '$timestamp' }}}}
// Observe sample data
{"exportVersion":4,"dashboards":{"dashboard-1":{"description":"","filters":[],"layout":[{"w":9,"h":2,"x":0,"y":2,"i":"item-1","minW":1,"maxW":10,"minH":1,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"w":9,"h":2,"x":0,"y":4,"i":"item-2","minW":1,"maxW":10,"minH":1,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"w":2,"h":2,"x":0,"y":0,"i":"item-3","minW":1,"maxW":10,"minH":1,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"i":"item-4","x":2,"y":0,"w":2,"h":2,"minW":1,"minH":1,"maxW":10,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"i":"item-5","x":4,"y":0,"w":2,"h":2,"minW":1,"minH":1,"maxW":10,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true}],"title":"kafkaPerformanceSource"}},"items":{"item-1":{"allowInteractiveFilters":true,"calculatedFields":[],"channels":{"x":{"channelType":"category","field":"timestampColumn","inferredType":"Date","type":"nominal","
@RWaltersMA
RWaltersMA / sink-chart-performance.charts
Created February 2, 2022 23:15
MongoDB Chart showing MongoDB Connector for Apache Kafka Sink Performance
{"exportVersion":4,"dashboards":{"dashboard-1":{"description":"","filters":[{"type":"Date","disabled":false,"name":"_insertedTS","settings":{"type":"absolute","absolute":{"from":{"enabled":true,"date":"2021-07-27","time":"17:30:00","inclusive":true},"to":{"enabled":false,"date":null,"time":"00:00:00","inclusive":false},"timezone":"Europe/Paris"},"relative":{"from":{"enabled":false,"tense":null,"value":"","unit":null},"until":{"enabled":false,"tense":null,"unit":"days","value":""}},"period":{"direction":"previous","count":"1","unit":"day","includeCurrent":true}},"linkedFields":[{"dataSourceId":"data-source-1","fieldPath":"_insertedTS"}]}],"layout":[{"w":10,"h":2,"x":0,"y":1,"i":"item-1","minW":1,"maxW":10,"minH":1,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"w":10,"h":2,"x":0,"y":3,"i":"item-2","minW":1,"maxW":10,"minH":1,"maxH":10,"moved":false,"static":false,"isDraggable":true,"isResizable":true},{"w":2,"h":1,"x":0,"y":0,"i":"item-3","minW":1,"maxW":10,"minH":1,"maxH":10,"m
@RWaltersMA
RWaltersMA / GenerateIoTData.py
Last active February 18, 2023 22:29
Generates sample IoT Data in Python for MongoDB, sample usage: python3 GenerateIoTData.py -s 3 -g 2 -n 200 -m 60
#Updated 2-15-19 changed from storing epoch time in integers to ISODate (mitigating Y2038 problem)
import random
import csv
import argparse
import pymongo
from datetime import date, timedelta
from datetime import datetime as dt
import threading
import sys
import json
const mongodb = require("mongodb");
run().catch(error => console.error(error));
async function run() {
console.log(new Date(), "Connecting to localhost");
const uri = "mongodb://127.0.0.1:27017/test?replicaSet=repl0";
const client = await mongodb.MongoClient.connect(
uri,
function(err, client) {
@RWaltersMA
RWaltersMA / CSharpTransactions.cs
Created October 16, 2018 17:53
Example C# code showing MongoDB Transactions using the MongoDB .NET Driver (2.7+)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.Serialization.Attributes;
namespace MongoDBTransaction
@RWaltersMA
RWaltersMA / ProdReviewFunc.cs
Last active November 9, 2020 14:42
Azure Function - HTTP Trigger that leverages MongoDB Atlas database
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;