@laioutr/app-hygraph 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +85 -0
- package/dist/module.d.mts +24 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +50 -0
- package/dist/runtime/app/blocks/.gitkeep +0 -0
- package/dist/runtime/app/public/app-hygraph/logo.svg +1 -0
- package/dist/runtime/app/sections/.gitkeep +0 -0
- package/dist/runtime/server/client/hygraph.d.ts +3 -0
- package/dist/runtime/server/client/hygraph.js +15 -0
- package/dist/runtime/server/const/passthroughTokens.d.ts +1 -0
- package/dist/runtime/server/const/passthroughTokens.js +2 -0
- package/dist/runtime/server/hygraph-utils/mediaMapper.d.ts +5 -0
- package/dist/runtime/server/hygraph-utils/mediaMapper.js +13 -0
- package/dist/runtime/server/media-library/hygraph.d.ts +2 -0
- package/dist/runtime/server/media-library/hygraph.js +29 -0
- package/dist/runtime/server/middleware/defineHygraph.d.ts +1 -0
- package/dist/runtime/server/middleware/defineHygraph.js +5 -0
- package/dist/runtime/server/orchestr/.gitkeep +0 -0
- package/dist/runtime/server/orchestr/blog/blogCollection.resolver.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogCollection.resolver.js +18 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.query.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.query.js +8 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.template.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionBySlug.template.js +11 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionPosts.link.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogCollectionPosts.link.js +21 -0
- package/dist/runtime/server/orchestr/blog/blogPost.resolver.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogPost.resolver.js +33 -0
- package/dist/runtime/server/orchestr/blog/blogPostBySlug.query.d.ts +2 -0
- package/dist/runtime/server/orchestr/blog/blogPostBySlug.query.js +20 -0
- package/dist/runtime/server/orchestr/plugins/zodFix.d.ts +2 -0
- package/dist/runtime/server/orchestr/plugins/zodFix.js +5 -0
- package/dist/runtime/server/queries/asset.d.ts +1 -0
- package/dist/runtime/server/queries/asset.js +14 -0
- package/dist/runtime/server/queries/blog.d.ts +2 -0
- package/dist/runtime/server/queries/blog.js +44 -0
- package/dist/runtime/server/queries/mediaLibrary.d.ts +1 -0
- package/dist/runtime/server/queries/mediaLibrary.js +13 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +3 -0
- package/package.json +74 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Laioutr GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Get your module up and running quickly.
|
|
3
|
+
|
|
4
|
+
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
+
- Name: Hygraph Laioutr
|
|
6
|
+
- Package name: @laioutr/app-hygraph
|
|
7
|
+
- Description: Laioutr Hygraph App
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Hygraph Laioutr
|
|
11
|
+
|
|
12
|
+
[![Laioutr][laioutr-src]][laioutr-href]
|
|
13
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
14
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
15
|
+
[![License][license-src]][license-href]
|
|
16
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
17
|
+
|
|
18
|
+
My new [Laioutr](https://laioutr.com) App for doing amazing things using Nuxt.
|
|
19
|
+
|
|
20
|
+
See [laioutr.com](https://laioutr.com) for more information about Laioutr.
|
|
21
|
+
|
|
22
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
23
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/@laioutr/app-hygraph?file=playground%2Fapp.vue) -->
|
|
24
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
<!-- Highlight some of the features your module provide here -->
|
|
29
|
+
|
|
30
|
+
- ⛰ Foo
|
|
31
|
+
- 🚠 Bar
|
|
32
|
+
- 🌲 Baz
|
|
33
|
+
|
|
34
|
+
## Quick Setup
|
|
35
|
+
|
|
36
|
+
Before installing dependencies, you need to create a copy of the `.npmrc.config` file called `.npmrc` and fill in the `NPM_LAIOUTR_TOKEN` with your npm token. You can find this token in your [project settings](https://cockpit.laioutr.cloud/o/_/p/_/settings).
|
|
37
|
+
|
|
38
|
+
- `pnpm i`
|
|
39
|
+
- `npx @laioutr/cli project fetch-rc -p <organization slug>/<project slug> -s <project secret key>` - This will load the `laioutrrc.json` file with the current remote project configuration.
|
|
40
|
+
- `pnpm dev:prepare`
|
|
41
|
+
- `pnpm orchestr-dev`
|
|
42
|
+
|
|
43
|
+
That's it! You can now use Hygraph Laioutr in your [Laioutr Frontend](https://laioutr.com) ✨
|
|
44
|
+
|
|
45
|
+
You can find a thorough guide on getting started with Laioutr development in our [developer guide](https://docs.laioutr.io/developer-guide/setup).
|
|
46
|
+
|
|
47
|
+
## Linting and Formatting
|
|
48
|
+
|
|
49
|
+
We use ESLint and Prettier to lint and format the code. This repository contains opinionated configurations for both tools. You can - of course - replace them with your own configurations.
|
|
50
|
+
|
|
51
|
+
## Publishing
|
|
52
|
+
|
|
53
|
+
To publish a new version, run `pnpm release`. This will:
|
|
54
|
+
|
|
55
|
+
- Run the tests
|
|
56
|
+
- Update the changelog
|
|
57
|
+
- Publish the package to npmjs.org
|
|
58
|
+
- Push the changes to the repository
|
|
59
|
+
|
|
60
|
+
### Private publishing
|
|
61
|
+
|
|
62
|
+
If you want to publish a private package to npm.laioutr.cloud, you need to:
|
|
63
|
+
|
|
64
|
+
1. Make sure you have a `.npmrc` with your private npm registry token.
|
|
65
|
+
2. Add this line to the root of the `package.json` file: `"publishConfig": { "registry": "https://npm.laioutr.cloud/" }`
|
|
66
|
+
3. Make sure your package-name follows the `@laioutr-org/<organization-slug>_<package-name>` format.
|
|
67
|
+
|
|
68
|
+
After that you can run `pnpm release` to publish the package to npm.laioutr.cloud.
|
|
69
|
+
|
|
70
|
+
## Contribution
|
|
71
|
+
|
|
72
|
+
Follow the [setup guide](https://docs.laioutr.io/developer-guide/setup) to get started.
|
|
73
|
+
|
|
74
|
+
<!-- Badges -->
|
|
75
|
+
|
|
76
|
+
[npm-version-src]: https://img.shields.io/npm/v/@laioutr/app-hygraph/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
77
|
+
[npm-version-href]: https://npmjs.com/package/@laioutr/app-hygraph
|
|
78
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@laioutr/app-hygraph.svg?style=flat&colorA=020420&colorB=00DC82
|
|
79
|
+
[npm-downloads-href]: https://npm.chart.dev/@laioutr/app-hygraph
|
|
80
|
+
[license-src]: https://img.shields.io/npm/l/@laioutr/app-hygraph.svg?style=flat&colorA=020420&colorB=00DC82
|
|
81
|
+
[license-href]: https://npmjs.com/package/@laioutr/app-hygraph
|
|
82
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
83
|
+
[nuxt-href]: https://nuxt.com
|
|
84
|
+
[laioutr-src]: https://img.shields.io/badge/%F0%9F%A6%99_Laioutr_App-702DCE
|
|
85
|
+
[laioutr-href]: https://www.laioutr.com/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The options the module adds to the nuxt.config.ts.
|
|
5
|
+
*/
|
|
6
|
+
interface ModuleOptions {
|
|
7
|
+
contentApiUrl: string;
|
|
8
|
+
imageBaseUrl: string;
|
|
9
|
+
token: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The config the module adds to nuxt.runtimeConfig.public['@laioutr/app-hygraph']
|
|
13
|
+
*/
|
|
14
|
+
interface RuntimeConfigModulePublic {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The config the module adds to nuxt.runtimeConfig['@laioutr/app-hygraph']
|
|
18
|
+
*/
|
|
19
|
+
interface RuntimeConfigModulePrivate extends ModuleOptions {
|
|
20
|
+
}
|
|
21
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
22
|
+
|
|
23
|
+
export { _default as default };
|
|
24
|
+
export type { ModuleOptions, RuntimeConfigModulePrivate, RuntimeConfigModulePublic };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule } from '@nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { registerLaioutrApp } from '@laioutr-core/kit';
|
|
4
|
+
|
|
5
|
+
const name = "@laioutr/app-hygraph";
|
|
6
|
+
const version = "1.1.0";
|
|
7
|
+
|
|
8
|
+
const module = defineNuxtModule({
|
|
9
|
+
meta: {
|
|
10
|
+
name,
|
|
11
|
+
version,
|
|
12
|
+
configKey: name
|
|
13
|
+
// configKey must match package name
|
|
14
|
+
},
|
|
15
|
+
// Default configuration options of the Nuxt module
|
|
16
|
+
defaults: {},
|
|
17
|
+
async setup(options, nuxt) {
|
|
18
|
+
const { resolve } = createResolver(import.meta.url);
|
|
19
|
+
const resolveRuntimeModule = (path) => resolve("./runtime", path);
|
|
20
|
+
nuxt.options.build.transpile.push(resolve("./runtime"));
|
|
21
|
+
nuxt.options.runtimeConfig[name] = defu(nuxt.options.runtimeConfig[name], options);
|
|
22
|
+
nuxt.options.nitro.publicAssets ??= [];
|
|
23
|
+
nuxt.options.nitro.publicAssets.push({
|
|
24
|
+
dir: resolveRuntimeModule("./app/public"),
|
|
25
|
+
maxAge: 60 * 60 * 24 * 7
|
|
26
|
+
// 7 days
|
|
27
|
+
});
|
|
28
|
+
nuxt.hook("laioutr:nuxtImageConfig", (config) => {
|
|
29
|
+
config.hygraph = {
|
|
30
|
+
baseURL: options.imageBaseUrl
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
await registerLaioutrApp({
|
|
34
|
+
name,
|
|
35
|
+
version,
|
|
36
|
+
orchestrDirs: [resolveRuntimeModule("server/orchestr")],
|
|
37
|
+
sections: [resolveRuntimeModule("app/sections")],
|
|
38
|
+
blocks: [resolveRuntimeModule("app/blocks")],
|
|
39
|
+
mediaLibraryProviders: [resolveRuntimeModule("./server/media-library/hygraph")]
|
|
40
|
+
});
|
|
41
|
+
if (nuxt.options._prepare) {
|
|
42
|
+
await installModule("@nuxt/image");
|
|
43
|
+
await installModule("@laioutr-core/frontend-core");
|
|
44
|
+
await installModule("@laioutr-core/orchestr");
|
|
45
|
+
await installModule("@laioutr-app/ui");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { module as default };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="24" fill="none"><path fill="#181B2A" fill-rule="evenodd" d="M11.175 3.2 8.382 4.8 5.588 6.4 2.794 8v9.6L5.588 16l2.794-1.6v-3.2l-2.794 1.6V9.6L8.382 8l2.793-1.6V16l-2.793 1.6-2.794 1.6-2.794 1.6L0 22.4 2.794 24l2.794-1.6 2.794-1.6 2.793-1.6 2.794-1.6V1.6L11.175 0v3.2Z" clip-rule="evenodd"/></svg>
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
export const hygraphClientFactory = () => {
|
|
3
|
+
const config = useRuntimeConfig()["@laioutr/app-hygraph"];
|
|
4
|
+
const request = async (query, variables = null) => {
|
|
5
|
+
const res = await fetch(config.contentApiUrl, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${config.token}`
|
|
9
|
+
},
|
|
10
|
+
body: JSON.stringify({ query, variables })
|
|
11
|
+
});
|
|
12
|
+
return res.json();
|
|
13
|
+
};
|
|
14
|
+
return { request };
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const blogPostsToken: any;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineMediaLibraryProvider } from "#imports";
|
|
2
|
+
import { hygraphClientFactory } from "../client/hygraph.js";
|
|
3
|
+
import { mapHygraphMedia } from "../hygraph-utils/mediaMapper.js";
|
|
4
|
+
import { MediaLibraryListQuery } from "../queries/mediaLibrary.js";
|
|
5
|
+
export default defineMediaLibraryProvider({
|
|
6
|
+
label: "Hygraph",
|
|
7
|
+
iconSrc: "/app-hygraph/logo.svg",
|
|
8
|
+
name: "hygraph",
|
|
9
|
+
list: async ({ limit, offset, search }) => {
|
|
10
|
+
const client = hygraphClientFactory();
|
|
11
|
+
const result = await client.request(MediaLibraryListQuery, {
|
|
12
|
+
skip: offset,
|
|
13
|
+
first: limit,
|
|
14
|
+
search
|
|
15
|
+
});
|
|
16
|
+
const items = result.data.assets.map(
|
|
17
|
+
(asset) => ({
|
|
18
|
+
media: mapHygraphMedia(asset),
|
|
19
|
+
previewUrl: asset.url
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
return {
|
|
23
|
+
items,
|
|
24
|
+
total: 0,
|
|
25
|
+
offset,
|
|
26
|
+
limit
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defineHygraph: any;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { defineOrchestr } from "#imports";
|
|
2
|
+
import { hygraphClientFactory } from "../client/hygraph.js";
|
|
3
|
+
export const defineHygraph = defineOrchestr.meta({
|
|
4
|
+
app: "@laioutr/app-hygraph"
|
|
5
|
+
}).use(async (ctx, next) => next({ context: { hygraph: hygraphClientFactory() } }));
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BlogCollectionBase } from "@laioutr-core/canonical-types/entity/blog-collection";
|
|
2
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
3
|
+
export default defineHygraph.componentResolver({
|
|
4
|
+
entityType: "BlogCollection",
|
|
5
|
+
label: "Blog Collection",
|
|
6
|
+
provides: [BlogCollectionBase],
|
|
7
|
+
resolve: async ({ entityIds, $entity }) => ({
|
|
8
|
+
entities: entityIds.map(
|
|
9
|
+
(id) => $entity({
|
|
10
|
+
id,
|
|
11
|
+
base: {
|
|
12
|
+
slug: "blog",
|
|
13
|
+
title: "Blog"
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BlogCollectionBySlug } from "@laioutr-core/canonical-types/blog";
|
|
2
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
3
|
+
export default defineHygraph.queryHandler({
|
|
4
|
+
implements: BlogCollectionBySlug,
|
|
5
|
+
run: async () => ({
|
|
6
|
+
id: "hygraph"
|
|
7
|
+
})
|
|
8
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlogCollectionBySlug } from "@laioutr-core/canonical-types/blog";
|
|
2
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
3
|
+
export default defineHygraph.queryTemplateProvider({
|
|
4
|
+
for: BlogCollectionBySlug,
|
|
5
|
+
run: async () => [
|
|
6
|
+
{
|
|
7
|
+
input: { slug: "hygraph" },
|
|
8
|
+
label: "Hygraph Blog"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BlogCollectionPostsLink } from "@laioutr-core/canonical-types/blog";
|
|
2
|
+
import { blogPostsToken } from "../../const/passthroughTokens.js";
|
|
3
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
4
|
+
import { BlogsQuery } from "../../queries/blog.js";
|
|
5
|
+
export default defineHygraph.linkHandler({
|
|
6
|
+
implements: BlogCollectionPostsLink,
|
|
7
|
+
run: async ({ context, entityIds, pagination, passthrough }) => {
|
|
8
|
+
const result = await context.hygraph.request(BlogsQuery, {
|
|
9
|
+
skip: pagination.offset,
|
|
10
|
+
first: pagination.limit
|
|
11
|
+
});
|
|
12
|
+
const blogs = result.data.blogs;
|
|
13
|
+
passthrough.set(blogPostsToken, blogs);
|
|
14
|
+
return {
|
|
15
|
+
links: entityIds.map((id) => ({
|
|
16
|
+
sourceId: id,
|
|
17
|
+
targetIds: blogs.map((blog) => blog.id)
|
|
18
|
+
}))
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BlogPostBase, BlogPostContent, BlogPostExcerpt, BlogPostMedia } from "@laioutr-core/canonical-types/entity/blog-post";
|
|
2
|
+
import { blogPostsToken } from "../../const/passthroughTokens.js";
|
|
3
|
+
import { mapHygraphMedia } from "../../hygraph-utils/mediaMapper.js";
|
|
4
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
5
|
+
export default defineHygraph.componentResolver({
|
|
6
|
+
entityType: "BlogPost",
|
|
7
|
+
label: "Blog Post",
|
|
8
|
+
provides: [BlogPostBase, BlogPostExcerpt, BlogPostContent, BlogPostMedia],
|
|
9
|
+
resolve: async ({ passthrough, $entity }) => {
|
|
10
|
+
const posts = passthrough.require(blogPostsToken);
|
|
11
|
+
return {
|
|
12
|
+
entities: posts.map(
|
|
13
|
+
(post) => $entity({
|
|
14
|
+
id: post.id,
|
|
15
|
+
base: {
|
|
16
|
+
slug: post.slug,
|
|
17
|
+
title: post.title,
|
|
18
|
+
publishedAt: new Date(post.publishedAt)
|
|
19
|
+
},
|
|
20
|
+
content: {
|
|
21
|
+
content: { html: post.content.html }
|
|
22
|
+
},
|
|
23
|
+
excerpt: {
|
|
24
|
+
excerpt: { html: post.content.html.slice(0, 100) }
|
|
25
|
+
},
|
|
26
|
+
media: {
|
|
27
|
+
image: post.image ? mapHygraphMedia(post.image) : { type: "image", sources: [{ provider: "none", src: "/placeholders/1x1.svg" }] }
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BlogPostBySlug, BlogPostBySlugNotFoundError } from "@laioutr-core/canonical-types/blog";
|
|
2
|
+
import { blogPostsToken } from "../../const/passthroughTokens.js";
|
|
3
|
+
import { defineHygraph } from "../../middleware/defineHygraph.js";
|
|
4
|
+
import { BlogPostBySlugQuery } from "../../queries/blog.js";
|
|
5
|
+
export default defineHygraph.queryHandler({
|
|
6
|
+
implements: BlogPostBySlug,
|
|
7
|
+
run: async ({ context, input, passthrough }) => {
|
|
8
|
+
const result = await context.hygraph.request(BlogPostBySlugQuery, {
|
|
9
|
+
slug: input.slug
|
|
10
|
+
});
|
|
11
|
+
const post = result.data.blog;
|
|
12
|
+
if (!post) {
|
|
13
|
+
throw new BlogPostBySlugNotFoundError(input.slug);
|
|
14
|
+
}
|
|
15
|
+
passthrough.set(blogPostsToken, [post]);
|
|
16
|
+
return {
|
|
17
|
+
id: post.id
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssetFragment = "\n #graphql\n fragment Asset on Asset {\n url\n fileName\n mimeType\n width\n height\n handle\n }\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const BlogsQuery = "\n #graphql\n \n #graphql\n \n #graphql\n fragment Asset on Asset {\n url\n fileName\n mimeType\n width\n height\n handle\n }\n\n fragment Blog on Blog {\n id\n title\n slug\n content {\n html\n }\n image {\n ...Asset\n }\n publishedAt\n }\n\n query Blogs($skip: Int, $first: Int) {\n blogs(skip: $skip, first: $first, orderBy: createdAt_DESC) {\n ...Blog\n }\n }\n";
|
|
2
|
+
export declare const BlogPostBySlugQuery = "\n #graphql\n \n #graphql\n \n #graphql\n fragment Asset on Asset {\n url\n fileName\n mimeType\n width\n height\n handle\n }\n\n fragment Blog on Blog {\n id\n title\n slug\n content {\n html\n }\n image {\n ...Asset\n }\n publishedAt\n }\n\n query BlogPostBySlug($slug: String!) {\n blog(where: { slug: $slug }) {\n ...Blog\n }\n }\n";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AssetFragment } from "./asset.js";
|
|
2
|
+
const BlogFragment = (
|
|
3
|
+
/* GraphQL */
|
|
4
|
+
`
|
|
5
|
+
#graphql
|
|
6
|
+
${AssetFragment}
|
|
7
|
+
fragment Blog on Blog {
|
|
8
|
+
id
|
|
9
|
+
title
|
|
10
|
+
slug
|
|
11
|
+
content {
|
|
12
|
+
html
|
|
13
|
+
}
|
|
14
|
+
image {
|
|
15
|
+
...Asset
|
|
16
|
+
}
|
|
17
|
+
publishedAt
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
);
|
|
21
|
+
export const BlogsQuery = (
|
|
22
|
+
/* GraphQL */
|
|
23
|
+
`
|
|
24
|
+
#graphql
|
|
25
|
+
${BlogFragment}
|
|
26
|
+
query Blogs($skip: Int, $first: Int) {
|
|
27
|
+
blogs(skip: $skip, first: $first, orderBy: createdAt_DESC) {
|
|
28
|
+
...Blog
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
);
|
|
33
|
+
export const BlogPostBySlugQuery = (
|
|
34
|
+
/* GraphQL */
|
|
35
|
+
`
|
|
36
|
+
#graphql
|
|
37
|
+
${BlogFragment}
|
|
38
|
+
query BlogPostBySlug($slug: String!) {
|
|
39
|
+
blog(where: { slug: $slug }) {
|
|
40
|
+
...Blog
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MediaLibraryListQuery = "\n #graphql\n \n #graphql\n fragment Asset on Asset {\n url\n fileName\n mimeType\n width\n height\n handle\n }\n\n query MediaLibraryList($skip: Int, $first: Int, $search: String) {\n assets(skip: $skip, first: $first, orderBy: createdAt_DESC, where: { _search: $search }) {\n ...Asset\n }\n }\n";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AssetFragment } from "./asset.js";
|
|
2
|
+
export const MediaLibraryListQuery = (
|
|
3
|
+
/* GraphQL */
|
|
4
|
+
`
|
|
5
|
+
#graphql
|
|
6
|
+
${AssetFragment}
|
|
7
|
+
query MediaLibraryList($skip: Int, $first: Int, $search: String) {
|
|
8
|
+
assets(skip: $skip, first: $first, orderBy: createdAt_DESC, where: { _search: $search }) {
|
|
9
|
+
...Asset
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
);
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@laioutr/app-hygraph",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Laioutr Hygraph App",
|
|
5
|
+
"repository": "your-org/@laioutr/app-hygraph",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.mts",
|
|
11
|
+
"import": "./dist/module.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/module.mjs",
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
".": [
|
|
18
|
+
"./dist/types.d.mts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "npm run dev:prepare && nuxi dev playground",
|
|
27
|
+
"dev:build": "nuxi build playground",
|
|
28
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"orchestr-dev": "npm run orchestr-dev:prepare && nuxi dev orchestr-playground",
|
|
31
|
+
"orchestr-dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare orchestr-playground",
|
|
32
|
+
"prepack": "nuxt-module-build build",
|
|
33
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish --access public && git push --follow-tags",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
36
|
+
"test:watch": "vitest watch"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@laioutr-core/canonical-types": "^0.20.0",
|
|
40
|
+
"@laioutr-core/core-types": "^0.24.0",
|
|
41
|
+
"@laioutr-core/kit": "^0.24.0",
|
|
42
|
+
"@nuxt/kit": "3.16.2",
|
|
43
|
+
"@pinia/colada": "0.17.1",
|
|
44
|
+
"@pinia/colada-nuxt": "0.2.1",
|
|
45
|
+
"@vueuse/core": "13.1.0",
|
|
46
|
+
"pinia": "3.0.2",
|
|
47
|
+
"zod": "3.25.61"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@laioutr-app/ui": "^1.24.4",
|
|
51
|
+
"@laioutr-core/orchestr-devtools": "^1.6.6",
|
|
52
|
+
"@laioutr/eslint-config": "^1.8.8",
|
|
53
|
+
"@laioutr/prettier-config": "^1.1.0",
|
|
54
|
+
"@nuxt/devtools": "^2.6.3",
|
|
55
|
+
"@nuxt/devtools-ui-kit": "2.5.0",
|
|
56
|
+
"@nuxt/module-builder": "1.0.1",
|
|
57
|
+
"@nuxt/schema": "3.16.2",
|
|
58
|
+
"@nuxt/test-utils": "3.19.1",
|
|
59
|
+
"@types/node": "latest",
|
|
60
|
+
"changelogen": "^0.6.2",
|
|
61
|
+
"eslint": "^9.35.0",
|
|
62
|
+
"nuxt": "3.16.2",
|
|
63
|
+
"typescript": "5.9.2",
|
|
64
|
+
"vitest": "3.1.1",
|
|
65
|
+
"vue-tsc": "2.2.10"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"@laioutr-core/frontend-core": "^0.24.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22.12.0",
|
|
72
|
+
"pnpm": ">=10.15.0"
|
|
73
|
+
}
|
|
74
|
+
}
|