Skip to content

Instantly share code, notes, and snippets.

diff --git a/Gemfile.lock b/Gemfile.lock
index 7ffd2aa..7672539 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -5,12 +5,16 @@ GEM
daemons (1.2.4)
eventmachine (1.2.3)
kgio (2.11.0)
- libv8 (5.7.492.65.1-x86_64-darwin-16)
+ libv8 (3.16.14.19)
@thomsbg
thomsbg / parse.js
Last active August 18, 2017 20:08
hand-rolled query parser
function parse(query) {
var curTerm = null
var curPhrase = null
var curKey = null
var result = []
for (var char of query) {
switch (char) {
case '"':
if (curPhrase != null) {
if (curKey) {
fragment StoryData {
title: String
image: Image
body: RichText
...
}
enum StoryStatus {
DRAFT
PENDING_APPROVAL
@thomsbg
thomsbg / trace.txt
Last active October 10, 2017 21:22
Mapstack publish log
This file has been truncated, but you can view the full file.
irb(main):041:0> e.publish
D, [2017-10-10T21:19:36.924658 #12604] DEBUG -- : EntryMetadata Load (0.7ms) SELECT `entry_metadatas`.* FROM `entry_metadatas` WHERE `entry_metadatas`.`entry_id` = 16127555 LIMIT 1
D, [2017-10-10T21:19:36.927315 #12604] DEBUG -- : (0.4ms) BEGIN
W, [2017-10-10T21:19:36.927601 #12604] WARN -- : save_entry_changes begin 1 transaction_stack: RealTransaction:nil:nil
D, [2017-10-10T21:19:36.933759 #12604] DEBUG -- : (0.9ms) SELECT COUNT(*) FROM `entries` INNER JOIN `stack_memberships` ON `entries`.`id` = `stack_memberships`.`card_id` WHERE `entries`.`type` IN ('Card', 'MapCard', 'ExplainerCard') AND `stack_memberships`.`stack_id` = 16127555 AND `entries`.`type` IN ('Card', 'MapCard', 'ExplainerCard') AND `entries`.`type` = 'MapCard'
D, [2017-10-10T21:19:36.950121 #12604] DEBUG -- : Status Load (0.4ms) SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
D, [2017-10-10T21:19:36.954371 #12604] DEBUG -- : User Load (0.6ms) SELECT `users`.* FROM `users` WH
@thomsbg
thomsbg / a.diff
Last active January 31, 2018 22:29
+ hello
-
-
(1 empty line)
entry(id: 1234) {
bylines {
name
url
}
}
# The API knows to fetch from various database sources,
# and returns full names vs usernames according to community rules,
# but leaves the formatting as HTML, and comma-joining up to the client
@thomsbg
thomsbg / volume.graphql
Last active March 26, 2018 21:05
volume + sbn schema stitching
# in tower:
query {
volumeProjects(communityId: 441, q: "Hillary") {
name # from volume api
contributorIds # from volume api, chorus user ids of the video's "contributors" (not sure if this is a thing, just an example)
contributors {
fullName # from sbn api, able to be efficiently resolved by batching multiple user-by-ids queries.
}
}
diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb
index 2e300fc0..02592ea2 100644
--- a/app/controllers/graphql_controller.rb
+++ b/app/controllers/graphql_controller.rb
@@ -9,6 +9,15 @@ def execute
}
result = HermanoGraphQL.schema.execute(query, variables: variables, context: context, operation_name: operation_name)
render json: result
+ rescue StandardError => e
+ e = e.cause while e.cause
@thomsbg
thomsbg / permissions.txt
Last active June 6, 2018 18:50
permissions query pseudocode
can user u perform operation o in scope s?
1. scopes = [s].concat(s.parents)
2. roles = RoleAssignment.where(user: u, scope: scopes).pluck(:role)
3. roles.any? { |role| ROLE_OPERATIONS_MAPPING[role].operations.include?(o) }
## or perhaps
1. scopes = [s].concat(s.parents)
@thomsbg
thomsbg / graphql-result.json
Created June 27, 2018 16:00
EditorCommunity error
{
"data": {
"community": null
},
"errors": [
{
"message": "Expected a value of type \"EntryType\" but received: MAP_STACK",
"locations": [
{
"line": 3,