Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ceb7697
wip
odama626 Aug 3, 2022
9339af9
refactor collection metadata
odama626 Aug 4, 2022
a3cc34a
Merge branch 'main' into mutate
odama626 Aug 5, 2022
9410310
add more metadata to collection
odama626 Aug 5, 2022
df774c0
add json assertsions
odama626 Aug 5, 2022
fdefe15
update mutations update file and memory :D, breaks ava watch
odama626 Aug 6, 2022
978b130
isolate context based on plugin, major breaking changes
odama626 Aug 6, 2022
b724de1
comments
odama626 Aug 6, 2022
2309708
added sourceMemory to allow for testing without a filesystem
odama626 Aug 6, 2022
27912b9
sourceVirtual
odama626 Aug 6, 2022
a1fd32d
disable star paths, add basic create mutations
odama626 Aug 7, 2022
22da949
handle creating new records with variable paths
odama626 Aug 8, 2022
ed214f3
Merge branch 'main' into mutate
odama626 Aug 8, 2022
f31e91f
remove nanoid-dictionary
odama626 Aug 8, 2022
e43f01c
cleanups, add required fields to resolvers, add upsert resolver
odama626 Aug 8, 2022
251ec6b
Merge branch 'main' into mutate
odama626 Aug 11, 2022
a18ee39
expose collectionResolvers to config
odama626 Aug 11, 2022
259d940
prettier
odama626 Aug 11, 2022
fe42961
test husky
odama626 Aug 11, 2022
40f4c26
test husky
odama626 Aug 11, 2022
02bc50f
remove stray arg
odama626 Aug 13, 2022
b82ddf5
Merge branch 'main' into mutate
odama626 Aug 13, 2022
4d98b05
Merge branch 'mutate' into collection-resolvers
odama626 Aug 13, 2022
30b9953
Merge branch 'main' into mutate
odama626 Aug 16, 2022
20158df
migrate sveltekit
odama626 Aug 16, 2022
215ecce
add error messages, prevent creating record with existing id, use ref…
odama626 Aug 16, 2022
04a9983
fix tests
odama626 Aug 16, 2022
231442f
Merge branch 'mutate' into collection-resolvers
odama626 Aug 16, 2022
eb4c5b0
linting
odama626 Aug 16, 2022
2bd9687
Merge branch 'mutate' into collection-resolvers
odama626 Aug 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/content/markdown/authors/Adam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Adam
friend: Amanda
enjoys:
- cats
- coding
- flatbread
---
7 changes: 7 additions & 0 deletions examples/content/markdown/authors/Amanda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Amanda
enjoys:
- cats
- coding
- flatbread
---
2 changes: 1 addition & 1 deletion examples/content/markdown/authors/daes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enjoys:
- cats
- coffee
- design
friend: 40s3
friend: Eva
date_joined: 2021-04-22T16:41:59.558Z
skills:
sitting: 304
Expand Down
2 changes: 1 addition & 1 deletion examples/content/markdown/authors/eva.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enjoys:
- mow mow
- sleepy time
- attention
friend: 2a3e
friend: Tony
image: eva.svg
date_joined: 2002-02-25T16:41:59.558Z
skills:
Expand Down
2 changes: 1 addition & 1 deletion examples/content/markdown/authors/tony.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enjoys:
- cats
- tea
- making this
friend: 40s3
friend: Eva
image: tony.svg
date_joined: 2021-02-25T16:41:59.558Z
skills:
Expand Down
2 changes: 1 addition & 1 deletion examples/content/markdown/authors/yoshi.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enjoys:
- encroaching upon personal space
- being concerned
- smooth jazz
friend: ab2c
friend: Daes
date_joined: 2018-10-25T16:23:59.558Z
skills:
sitting: 10
Expand Down
4 changes: 2 additions & 2 deletions examples/content/markdown/posts/anotha-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
id: 92348fds-453fdh-59ddsd-3332-09876
title: 'Test post A'
authors:
- 40s3
- 2a3e
- Eva
- Tony
rating: 84.3
---

Expand Down
4 changes: 2 additions & 2 deletions examples/content/markdown/posts/b.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
id: 2348fds-563fdh-59ddsd-3332-09876
title: 'Test post B'
authors:
- 1111
- ab2c
- Ushi
- Daes
rating: 44
---

Expand Down
4 changes: 2 additions & 2 deletions examples/content/markdown/posts/example-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
id: sdfsdf-23423-sdfsd-23444-dfghf
title: 'Example post of things'
authors:
- 2a3e
- 40s3
- Tony
- Eva
rating: 74
---

Expand Down
3 changes: 1 addition & 2 deletions examples/content/markdown/posts/soup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
id: jksfd4-234fdh-5345fj-3455-09836
title: 'Soup Reflection'
authors:
- r3c6
- ab2c
- Yoshi
rating: 96
---

Expand Down
6 changes: 3 additions & 3 deletions examples/nextjs/flatbread.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ export default defineConfig({
content: [
{
path: 'content/markdown/posts',
collection: 'Post',
name: 'Post',
refs: {
authors: 'Author',
},
},
{
path: 'content/markdown/posts/[category]/[slug].md',
collection: 'PostCategory',
name: 'PostCategory',
refs: {
authors: 'Author',
},
},
{
path: 'content/markdown/posts/**/*.md',
collection: 'PostCategoryBlob',
name: 'PostCategoryBlob',
refs: {
authors: 'Author',
},
Expand Down
37 changes: 23 additions & 14 deletions examples/sveltekit/flatbread.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,42 @@ const transformerConfig = {
export default defineConfig({
source: sourceFilesystem(),
transformer: [transformerMarkdown(transformerConfig), transformerYaml()],

collectionResolvers: [
function fakeResolver(schemaComposer, args) {
const { name } = args;

schemaComposer.Query.addFields({
[`fake${name}`]: {
type: 'String',
description: `fake resolver`,
resolve() {
return `fake ${name}!`;
},
},
});
},
],

content: [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename content to collections for consistency?

{
path: 'content/markdown/posts',
collection: 'Post',
name: 'Post',
refs: {
authors: 'Author',
},
},
{
path: 'content/markdown/posts/[category]/[slug].md',
collection: 'PostCategory',
refs: {
authors: 'Author',
},
},
{
path: 'content/markdown/posts/**/*.md',
collection: 'PostCategoryBlob',
name: 'PostCategory',
refs: {
authors: 'Author',
},
},
{
path: 'content/markdown/authors',
collection: 'Author',
name: 'Author',
referenceField: 'name',
refs: {
friend: 'Author',
},
Expand All @@ -54,20 +65,18 @@ export default defineConfig({
},
{
path: 'content/yaml/authors',
collection: 'YamlAuthor',
name: 'YamlAuthor',
refs: {
friend: 'YamlAuthor',
},
},
{
path: 'content/markdown/deeply-nested',
collection: 'OverrideTest',
name: 'OverrideTest',
overrides: [
{
field: 'deeply.nested',
type: 'String',
test: undefined,
test2: null,
resolve: (source) => String(source).toUpperCase(),
},
{
Expand Down
55 changes: 55 additions & 0 deletions examples/sveltekit/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script lang="ts">
import { browser } from '$app/env';
import Pane from './../lib/components/Pane.svelte';

/** @type {import('./$types').PageData}*/
export let data;

if (browser) {
import('svimg/dist/s-image');
}

export let error = null;
if (error) console.error(error);

function joinAuthors(authors) {
return authors?.map((author) => author.name).join(', ');
}
</script>

<div class="grid grid-cols-2 divide-x-2 divide-black">
<Pane label="JSON Output">
<pre
class="overflow-auto p-3"
style="height: calc(100vh - 3.5rem);">
<code class="text-sm">
{JSON.stringify(data, null, 2)}
</code>
</pre>
</Pane>
<Pane label="Frontend">
{#each data.allPostCategories as post, _ (post.id)}
<article class="m-3 border border-opacity-20 bg-gray-50 p-3">
<h3 class="text-xl font-medium">{post.title}</h3>
<ul>
<li class="text-xs font-semibold text-gray-500">
<div class="flex">
{#each post.authors as author}
<div>
<div class="h-12 w-12">
<s-image {...author.image} />
</div>
{author.name}
</div>
{/each}
</div>
</li>
<li class="text-xs font-semibold text-gray-500">
Rating: {post.rating}
</li>
</ul>
<div>{@html post._content.html}</div>
</article>
{/each}
</Pane>
</div>
79 changes: 79 additions & 0 deletions examples/sveltekit/src/routes/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { error } from '@sveltejs/kit';

export const load = async ({ fetch }) => {
const query = `
query PostCategory {
allPostCategories (sortBy: "title", order: DESC) {
_metadata {
sourceContext {
filename
slug
}
collection
}
id
title
category
slug
rating
_content {
raw
html
excerpt
timeToRead
}
authors {
_metadata {
sourceContext {
slug
}
}
id
name
entity
enjoys
image {
srcset
srcsetwebp
srcsetavif
placeholder
aspectratio
}
friend {
name
date_joined
}
date_joined
skills {
sitting
breathing
liquid_consumption
existence
sports
}
}
}
}
`;

try {
const response = await fetch('http://localhost:5057/graphql', {
body: JSON.stringify({
query,
}),
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
method: 'POST',
});

const { data, errors } = await response.json();

if (errors)
throw error(500, errors.map(({ message }) => message).join('\\n'));
return data;
} catch (e) {
throw error(500, 'Failed to load data');
}
};
Loading