Skip to content

Instantly share code, notes, and snippets.

@CacheControl
CacheControl / apollo-rover-could-not-parse-partial-schema.md
Created Jun 15, 2021
Apollo rover "Could not parse partial schema as AST."
View apollo-rover-could-not-parse-partial-schema.md

"Could not parse partial schema as AST."

Ran into this when using rover to parse a graphql schema that had a syntax error. The issue was caused by double quotes in a graphql comment, something allowed by the framework I was using to render the schema (DGS).

"""Placing quotes around "strings" in graphql comments causes this error""""  # INVALID

The fix is to remove or replace the double quotes, e.g.

@CacheControl
CacheControl / Dockerfile
Created Oct 9, 2020
dockerfile for bundling graphicsmagick within a lambda
View Dockerfile
FROM amazonlinux
# epel-release required for graphicsmagick
RUN amazon-linux-extras install epel
RUN yum -y --nogpgcheck install gcc-c++ make GraphicsMagick yum-utils rpmdevtools
# node.js 12 (also adds npm)
RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash -
RUN yum -y --nogpgcheck install nodejs
@CacheControl
CacheControl / http-request-promise.js
Created Mar 22, 2019
node.js http request to promise
View http-request-promise.js
const http = require('http');
return new Promise((resolve, reject) => {
http.get(url, (res) => {
if (res.statusCode >= 400) {
const err = new Error(`${res.statusCode} - ${res.statusMessage}`);
err.statusCode = res.statusCode;
return reject(err);
}
return resolve(res);
View swagger-json-schema-validator.js
// there are many json-schema validators available, I prefer ajv
let Ajv = require('ajv')
let ajv = Ajv({ allErrors:true })
let swagger = require('./docs/my-swagger-definition')
// validation middleware
let validateSchema = (parameters) => {
return (req, res, next) => {
let errors = []
parameters.map(param => {
@CacheControl
CacheControl / partition_function.sql
Last active May 20, 2019
Postgresql Table Partitioning Function
View partition_function.sql
CREATE OR REPLACE FUNCTION
public.insert_comment()
RETURNS TRIGGER AS
$BODY$
DECLARE
_start_dt text;
_end_dt text;
_table_name text;
BEGIN
IF NEW.id IS NULL THEN
View Movie View
var MovieView = Backbone.View.extend({
listTemplate: _.template($("#movieTemplate").html()),
editTemplate: _.template($("#movieEditTemplate").html()),
initialize: function() {
this.model.on('change', this.render, this);
this.model.on('destroy', this.remove, this);
this.model.on('error', this.invalid, this);
},
render: function() {
this.$el.html(this.listTemplate(this.model.toJSON()));