Skip to content

Instantly share code, notes, and snippets.

@thomsbg
thomsbg / inline_input.graphql
Last active May 12, 2020 16:00
List + Association (Inline) Input patterns
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 22:36
Non-draftable fields from the content-api story schema
# 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 21:53
No parent container
interface EntryRevision {
title: String
body: EntryBody
# etc
}
# A published unit of content
type Entry implements EntryRevision {
draft: EntryDraft
}
query {
entryBody(uuid: "b4c7210f-0593-4ab2-85d9-abab343fcc09") {
components {
blockquote {
paragraphs {
ops
}
}
grouping {
layout
@thomsbg
thomsbg / normalize.js
Last active April 10, 2020 21:51
normalize delta
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();
}
[
{
"type": "EntryBodyParagraphComponent",
"ops": [
{
"insert": "a man ",
"attributes": {}
},
{
"insert": "a plan",
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 February 26, 2020 21:31
ApiClient plain class
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 February 24, 2020 22:15
Flat component list read format
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 21:12
Streams use-cases
| | 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