Skip to content

Instantly share code, notes, and snippets.

Avatar

Blake Thomson thomsbg

View GitHub Profile
@thomsbg
thomsbg / inline_input.graphql
Last active May 12, 2020
List + Association (Inline) Input patterns
View inline_input.graphql
input <%= association %>InlineInput {
connect: <%= association %>UniqueIdInput
create: <%= association %>CreateInput
createOrUpdate: <%= association %>CreateOrUpdateInlineInput
# Update-only. Should these be in a separate type?
update: <%= association %>UpdateInlineInput
disconnect: Boolean
}
@thomsbg
thomsbg / fields.txt
Created May 7, 2020
Non-draftable fields from the content-api story schema
View fields.txt
# applies to published revision only
"slug_prefix"
"comments_closed"
"comments_auto_closed_at"
# applies to draft revision only / story editor metadata
"hidden"
"embargoed"
"publish_scheduled_for"
"trashed_at"
@thomsbg
thomsbg / schema.graphql
Last active May 7, 2020
No parent container
View schema.graphql
interface EntryRevision {
title: String
body: EntryBody
# etc
}
# A published unit of content
type Entry implements EntryRevision {
draft: EntryDraft
}
View entrybody.graphql
query {
entryBody(uuid: "b4c7210f-0593-4ab2-85d9-abab343fcc09") {
components {
blockquote {
paragraphs {
ops
}
}
grouping {
layout
@thomsbg
thomsbg / normalize.js
Last active Apr 10, 2020
normalize delta
View normalize.js
function eachHardLine(delta, fn) {
let buffer = new Delta();
new Delta(delta).eachLine((line, attributes) => {
buffer = buffer.concat(line);
if (attributes.br) {
buffer.insert('\n', attributes);
} else {
fn(buffer, attributes);
buffer = new Delta();
}
View entry_body_parse.json
[
{
"type": "EntryBodyParagraphComponent",
"ops": [
{
"insert": "a man ",
"attributes": {}
},
{
"insert": "a plan",
View gist:6edf35d51f7ae6a3d1b621fa6ba19ede
diff --git a/test/chorus_auth_client_test.rb b/test/chorus_auth_client_test.rb
index c383a1528b8f..377455808ea5 100644
--- a/test/chorus_auth_client_test.rb
+++ b/test/chorus_auth_client_test.rb
@@ -104,7 +104,8 @@ class ChorusAuthClientTest < Minitest::Test
end
def test_decode_jwt!
- VCR.use_cassette('decode_jwt') do
+ stub_request(:get, 'https://chorus-development.auth0.com/.well-known/jwks.json')
@thomsbg
thomsbg / api_client.js
Last active Feb 26, 2020
ApiClient plain class
View api_client.js
class ApiClient {
constructor(jwt) {
// parse + verify jwt
// set properties based on jwt claims
}
user() {
if (this.user_id) {
return towerRequest(USER_INFO, { user_id: this.user_id });
} else {
@thomsbg
thomsbg / components.graphql
Last active Feb 24, 2020
Flat component list read format
View components.graphql
type EntryBody {
components: [EntryBodyComponent]
}
# all components have a plaintext and an html representation
interface EntryBodyComponent {
plaintext: String
html: String
}
@thomsbg
thomsbg / wtf.txt
Created May 8, 2019
Streams use-cases
View wtf.txt
| | draft story | pub'd story |
--------------------------------------------
| draft stream | NO | YES |
| pub'd stream | YES | YES |
This implies:
A draft stream can only contain pub'd stories
A draft story can only contain pub'd streams
You can’t perform that action at this time.