eddev 2.3.11-beta.8 → 2.3.13
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/dist/app/entry/MetaTags.d.ts +1 -1
- package/dist/app/entry/MetaTags.d.ts.map +1 -1
- package/dist/app/entry/MetaTags.js +2 -0
- package/dist/app/entry/hydration-script.js +1 -1
- package/dist/app/lib/blocks/BlockPropMutator.d.ts +1 -1
- package/dist/app/lib/blocks/BlockPropMutator.d.ts.map +1 -1
- package/dist/app/lib/blocks/SlotBlocks.d.ts +1 -1
- package/dist/app/lib/blocks/SlotBlocks.d.ts.map +1 -1
- package/dist/app/lib/blocks/SlotBlocks.js +2 -2
- package/dist/app/lib/blocks/block-debugger.d.ts +3 -3
- package/dist/app/lib/blocks/block-debugger.d.ts.map +1 -1
- package/dist/app/lib/blocks/block-debugger.js +1 -1
- package/dist/app/lib/blocks/block-utils.d.ts +2 -2
- package/dist/app/lib/blocks/block-utils.d.ts.map +1 -1
- package/dist/app/lib/blocks/block-utils.js +10 -3
- package/dist/app/lib/blocks/builtin-blocks.js +1 -1
- package/dist/app/lib/blocks/defineBlock.js +2 -2
- package/dist/app/lib/blocks/editor/EditorHighlights.js +1 -1
- package/dist/app/lib/blocks/editor/create-block.d.ts +1 -1
- package/dist/app/lib/blocks/editor/create-block.d.ts.map +1 -1
- package/dist/app/lib/blocks/editor/root-blocks.d.ts.map +1 -1
- package/dist/app/lib/blocks/editor/root-blocks.js +4 -4
- package/dist/app/lib/devtools/components/DevMenu.js +4 -4
- package/dist/app/lib/devtools/components/DevUI.js +5 -5
- package/dist/app/lib/devtools/components/panels/AppDataPanel.js +4 -4
- package/dist/app/lib/devtools/components/panels/QueriesPanel.js +1 -1
- package/dist/app/lib/devtools/components/panels/RoutePanel.d.ts +1 -1
- package/dist/app/lib/devtools/components/panels/RoutePanel.d.ts.map +1 -1
- package/dist/app/lib/devtools/components/panels/RoutePanel.js +8 -8
- package/dist/app/lib/devtools/components/panels/StructurePanel.js +8 -8
- package/dist/app/lib/devtools/components/panels/index.js +5 -5
- package/dist/app/lib/devtools/components/ui/JSONInspector.js +2 -2
- package/dist/app/lib/devtools/components/ui/Panel.js +1 -1
- package/dist/app/lib/devtools/components/ui/QueryMonitorDisplay.d.ts +1 -1
- package/dist/app/lib/devtools/components/ui/QueryMonitorDisplay.d.ts.map +1 -1
- package/dist/app/lib/devtools/components/ui/QueryMonitorDisplay.js +3 -3
- package/dist/app/lib/devtools/components/ui/TabBar.js +2 -2
- package/dist/app/lib/devtools/components/ui/Tabs.js +2 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +5 -5
- package/dist/app/lib/dynamic/dynamic.js +1 -1
- package/dist/app/lib/hooks/query-hooks.d.ts +9 -9
- package/dist/app/lib/hooks/query-hooks.d.ts.map +1 -1
- package/dist/app/lib/hooks/query-hooks.js +2 -1
- package/dist/app/lib/integrations/gravityforms/createGravityFormComponent.d.ts +3 -3
- package/dist/app/lib/integrations/gravityforms/createGravityFormComponent.d.ts.map +1 -1
- package/dist/app/lib/integrations/gravityforms/createGravityFormComponent.js +1 -1
- package/dist/app/lib/integrations/gravityforms/field-types.d.ts +1 -1
- package/dist/app/lib/integrations/gravityforms/field-types.d.ts.map +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +1 -509
- package/dist/app/lib/legacy-stitches/createStitches.d.ts.map +1 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -1
- package/dist/app/lib/runtime/apiConfig.d.ts +15 -0
- package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -1
- package/dist/app/lib/runtime/errorHandling.d.ts +2 -2
- package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -1
- package/dist/app/lib/runtime/index.d.ts +2 -2
- package/dist/app/lib/runtime/index.d.ts.map +1 -1
- package/dist/app/lib/runtime/index.js +2 -2
- package/dist/app/server/proxy-wp-admin.d.ts.map +1 -1
- package/dist/app/server/proxy-wp-admin.js +1 -0
- package/dist/app/server/rpc.d.ts +1 -1
- package/dist/app/server/rpc.d.ts.map +1 -1
- package/dist/app/server/server-context.d.ts +3 -3
- package/dist/app/server/server-context.d.ts.map +1 -1
- package/dist/app/server/server-context.js +5 -5
- package/dist/app/server/utils/content-security.d.ts +2 -2
- package/dist/app/server/utils/content-security.d.ts.map +1 -1
- package/dist/app/utils/trpc-client.d.ts.map +1 -1
- package/dist/app/utils/trpc-client.js +19 -3
- package/dist/app/utils/wp.d.ts +10 -10
- package/dist/app/utils/wp.d.ts.map +1 -1
- package/dist/node/cli/cli.js +3 -1
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.d.ts.map +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/dev-server.js +1 -1
- package/dist/node/compiler/get-vite-config.d.ts.map +1 -1
- package/dist/node/compiler/get-vite-config.js +2 -0
- package/dist/node/compiler/vinxi-app.d.ts +1 -1
- package/dist/node/compiler/vinxi-app.d.ts.map +1 -1
- package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -1
- package/dist/node/compiler/vinxi-codegen.js +2 -3
- package/dist/node/project/favicons.d.ts +1 -1
- package/dist/node/project/favicons.d.ts.map +1 -1
- package/dist/node/storybook/index.js +1 -1
- package/dist/node/utils/fetch-wp.d.ts.map +1 -1
- package/dist/node/utils/fetch-wp.js +2 -1
- package/dist/node/utils/fs.d.ts +22 -19
- package/dist/node/utils/fs.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/eddev/SKILL.md +156 -0
- package/skills/eddev/docs/acf/admin-panel-widgets.mdx +99 -0
- package/skills/eddev/docs/acf/custom-enums.mdx +75 -0
- package/skills/eddev/docs/acf/custom-fields.mdx +131 -0
- package/skills/eddev/docs/acf.mdx +31 -0
- package/skills/eddev/docs/blocks/block-definition.mdx +189 -0
- package/skills/eddev/docs/blocks/core-blocks.mdx +86 -0
- package/skills/eddev/docs/blocks/data-and-editing.mdx +219 -0
- package/skills/eddev/docs/blocks/editor-config.mdx +157 -0
- package/skills/eddev/docs/blocks/nested-blocks.mdx +129 -0
- package/skills/eddev/docs/blocks/overview.mdx +58 -0
- package/skills/eddev/docs/blocks/template-parts.mdx +131 -0
- package/skills/eddev/docs/config.mdx +200 -0
- package/skills/eddev/docs/design/color.mdx +185 -0
- package/skills/eddev/docs/design/favicons.mdx +103 -0
- package/skills/eddev/docs/design/grid.mdx +120 -0
- package/skills/eddev/docs/design/icons.mdx +197 -0
- package/skills/eddev/docs/design/responsive-scaling.mdx +312 -0
- package/skills/eddev/docs/design/type.mdx +125 -0
- package/skills/eddev/docs/devtool/cli.mdx +201 -0
- package/skills/eddev/docs/devtool/overlay.mdx +5 -0
- package/skills/eddev/docs/getting-started.mdx +53 -0
- package/skills/eddev/docs/graphql/extending.mdx +186 -0
- package/skills/eddev/docs/graphql/fragments.mdx +107 -0
- package/skills/eddev/docs/graphql/global-data.mdx +47 -0
- package/skills/eddev/docs/graphql/infinite-queries.mdx +95 -0
- package/skills/eddev/docs/graphql/mutation-hooks.mdx +111 -0
- package/skills/eddev/docs/graphql/query-hooks.mdx +122 -0
- package/skills/eddev/docs/graphql/tooling.mdx +50 -0
- package/skills/eddev/docs/graphql.mdx +97 -0
- package/skills/eddev/docs/guides/color-schemes.mdx +204 -0
- package/skills/eddev/docs/guides/integrations.mdx +3 -0
- package/skills/eddev/docs/guides/page-transitions.mdx +5 -0
- package/skills/eddev/docs/guides/seo.mdx +5 -0
- package/skills/eddev/docs/guides/state-management.mdx +5 -0
- package/skills/eddev/docs/infra/caching.mdx +9 -0
- package/skills/eddev/docs/infra/deployment.mdx +13 -0
- package/skills/eddev/docs/infra/local.mdx +5 -0
- package/skills/eddev/docs/infra/security.mdx +11 -0
- package/skills/eddev/docs/routing/api.mdx +731 -0
- package/skills/eddev/docs/routing/custom.mdx +123 -0
- package/skills/eddev/docs/routing/full-details.mdx +37 -0
- package/skills/eddev/docs/routing/wordpress.mdx +70 -0
- package/skills/eddev/docs/routing.mdx +18 -0
- package/skills/eddev/docs/serverless/functions.mdx +436 -0
- package/skills/eddev/docs/serverless.mdx +202 -0
- package/skills/eddev/docs/snippets/automated-block-layouts.mdx +97 -0
- package/skills/eddev/docs/snippets/custom-routes-and-urls.mdx +91 -0
- package/skills/eddev/docs/snippets/multiple-editable-zones.mdx +87 -0
- package/skills/eddev/docs/snippets/querying-specific-blocks.mdx +164 -0
- package/skills/eddev/docs/snippets/submitting-forms-to-rpc.mdx +91 -0
- package/skills/eddev/docs/snippets/svgs.mdx +38 -0
- package/skills/eddev/docs/snippets/type-safe-acf-dropdowns.mdx +72 -0
- package/skills/eddev/docs/snippets.mdx +19 -0
- package/skills/eddev/docs/software.mdx +19 -0
- package/skills/eddev/docs/stack/how-it-works.mdx +50 -0
- package/skills/eddev/docs/stack/overview.mdx +56 -0
- package/skills/eddev/docs/stack/spa-vs-ssr.mdx +52 -0
- package/skills/eddev/docs/views/app-view.mdx +97 -0
- package/skills/eddev/docs/views/page-templates.mdx +82 -0
- package/skills/eddev/docs/views/queries.mdx +116 -0
- package/skills/eddev/docs/views.mdx +63 -0
- package/skills/eddev/index.mdx +79 -0
- package/tsconfig.app.json +2 -2
- package/tsconfig.node.json +6 -3
- package/types.env.d.ts +1 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Query Hooks (/docs/graphql/query-hooks)
|
|
2
|
+
|
|
3
|
+
**Generate browser runtime query hooks from files in queries.**
|
|
4
|
+
|
|
5
|
+
Query hooks are for data that should be fetched at runtime in the browser, such as search results, filters, live previews, and user-controlled lookups.
|
|
6
|
+
|
|
7
|
+
They are generated from GraphQL query files in `queries/`. The generated hooks live in `hooks/queries.ts` and wrap TanStack Query.
|
|
8
|
+
|
|
9
|
+
<Callout type="warning">
|
|
10
|
+
Query hooks are browser-side runtime fetches. They are not executed as part of the server-rendered route payload, unlike View, Block, and Global Data queries.
|
|
11
|
+
|
|
12
|
+
Once a query hook renders in the browser, it follows TanStack Query behavior and will run automatically unless you pass `enabled: false`.
|
|
13
|
+
</Callout>
|
|
14
|
+
|
|
15
|
+
## Naming Rules [#naming-rules]
|
|
16
|
+
|
|
17
|
+
GraphQL query hook files have strict naming rules enforced by codegen:
|
|
18
|
+
|
|
19
|
+
1. Files live under `queries/`, excluding `queries/fragments/`.
|
|
20
|
+
2. The filename must start with `Use`.
|
|
21
|
+
3. The GraphQL operation name must match the filename.
|
|
22
|
+
4. Each file can contain only one operation.
|
|
23
|
+
|
|
24
|
+
Subdirectories are fine. They affect the runtime query name, but not the hook name.
|
|
25
|
+
|
|
26
|
+
```graphql filename="queries/posts/UsePostsSearch.graphql"
|
|
27
|
+
query UsePostsSearch($q: String) {
|
|
28
|
+
posts(where: { search: $q }, first: 100) {
|
|
29
|
+
nodes {
|
|
30
|
+
title
|
|
31
|
+
uri
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This generates `usePostsSearch` in `hooks/queries.ts`.
|
|
38
|
+
|
|
39
|
+
## Basic Usage [#basic-usage]
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Link } from "eddev/routing"
|
|
43
|
+
import { useState } from "react"
|
|
44
|
+
import { usePostsSearch } from "@hooks/queries"
|
|
45
|
+
|
|
46
|
+
export function ExampleSearch() {
|
|
47
|
+
const [search, setSearch] = useState("")
|
|
48
|
+
const lookup = usePostsSearch(
|
|
49
|
+
{ q: search },
|
|
50
|
+
{ enabled: search.length >= 3 },
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<input type="search" value={search} onChange={(e) => setSearch(e.currentTarget.value)} />
|
|
56
|
+
|
|
57
|
+
{lookup.isLoading ? (
|
|
58
|
+
<p>Loading...</p>
|
|
59
|
+
) : lookup.isError ? (
|
|
60
|
+
<p>{lookup.error.message}</p>
|
|
61
|
+
) : lookup.data ? (
|
|
62
|
+
<ul>
|
|
63
|
+
{lookup.data.posts?.nodes?.map((node) => (
|
|
64
|
+
<li key={node.uri}>
|
|
65
|
+
<Link href={node.uri!}>{node.title}</Link>
|
|
66
|
+
</li>
|
|
67
|
+
))}
|
|
68
|
+
</ul>
|
|
69
|
+
) : null}
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Use `enabled: false` or an expression like `enabled: search.length >= 3` when the query should wait for user input.
|
|
76
|
+
|
|
77
|
+
## Hook API [#hook-api]
|
|
78
|
+
|
|
79
|
+
Generated query hooks accept:
|
|
80
|
+
|
|
81
|
+
1. Query variables, or `undefined` if the query has no variables.
|
|
82
|
+
2. TanStack Query options, except `queryKey` and `queryFn`, which eddev manages.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const lookup = usePostsSearch(
|
|
86
|
+
{ q: search },
|
|
87
|
+
{
|
|
88
|
+
enabled: search.length >= 3,
|
|
89
|
+
staleTime: 60_000,
|
|
90
|
+
refetchOnWindowFocus: false,
|
|
91
|
+
},
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The returned object is a TanStack `UseQueryResult`, including:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
type QueryResult<T> = {
|
|
99
|
+
status: "pending" | "error" | "success"
|
|
100
|
+
isLoading: boolean
|
|
101
|
+
isSuccess: boolean
|
|
102
|
+
isError: boolean
|
|
103
|
+
error: QueryError | null
|
|
104
|
+
data: T | undefined
|
|
105
|
+
refetch: () => Promise<unknown>
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Manual Fetching [#manual-fetching]
|
|
110
|
+
|
|
111
|
+
Each generated query hook also has a static `.fetch()` method for rare non-hook usage.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { usePostsSearch } from "@hooks/queries"
|
|
115
|
+
|
|
116
|
+
async function loadPosts() {
|
|
117
|
+
const result = await usePostsSearch.fetch({ q: "festival" })
|
|
118
|
+
return result.posts?.nodes ?? []
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Prefer the hook in React components so loading, error, cache, and refetch states stay consistent.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# GraphQL Tooling (/docs/graphql/tooling)
|
|
2
|
+
|
|
3
|
+
**Use generated schema files with editor tooling and GraphiQL.**
|
|
4
|
+
|
|
5
|
+
eddev generates enough local GraphQL metadata for editor tooling to understand
|
|
6
|
+
the current WordPress schema and the project's `.graphql` files.
|
|
7
|
+
|
|
8
|
+
## Generated Tooling Files [#generated-tooling-files]
|
|
9
|
+
|
|
10
|
+
When `yarn dev` is running, eddev keeps the local GraphQL tooling files up to
|
|
11
|
+
date:
|
|
12
|
+
|
|
13
|
+
* `schema.json` is written by the TypeScript GraphQL codegen process.
|
|
14
|
+
* `.graphqlrc.json` is written by the PHP dev bootstrap. It points tooling at
|
|
15
|
+
`schema.json`, the `/graphql` endpoint, and the fragment document glob.
|
|
16
|
+
|
|
17
|
+
These files are development artifacts. They let your editor validate fields,
|
|
18
|
+
variables, fragments, and operation names against the same schema used by the
|
|
19
|
+
site.
|
|
20
|
+
|
|
21
|
+
## VS Code [#vs-code]
|
|
22
|
+
|
|
23
|
+
Install these extensions:
|
|
24
|
+
|
|
25
|
+
* [GraphQL Language Feature Support](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql)
|
|
26
|
+
* [GraphQL Syntax Highlighting](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql-syntax)
|
|
27
|
+
|
|
28
|
+
With the generated config in place, VS Code can autocomplete fields and report
|
|
29
|
+
invalid selections directly in `.graphql` files.
|
|
30
|
+
|
|
31
|
+
[GraphQL Inline Operation Execution](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql-execution)
|
|
32
|
+
also works with the same config, but the built-in GraphiQL IDE is usually a
|
|
33
|
+
better place to run exploratory queries.
|
|
34
|
+
|
|
35
|
+
## GraphiQL IDE [#graphiql-ide]
|
|
36
|
+
|
|
37
|
+
WPGraphQL includes a GraphiQL IDE in WordPress admin. Use it to inspect type
|
|
38
|
+
names, test schema extensions, and build selections before moving them into
|
|
39
|
+
project files.
|
|
40
|
+
|
|
41
|
+
Fragments under `queries/fragments/**/*.graphql` are available to project query
|
|
42
|
+
files without adding `#import` lines. In GraphiQL, paste the fragment definition
|
|
43
|
+
alongside the query when you want to execute the same selection manually.
|
|
44
|
+
|
|
45
|
+
<Callout type="info">
|
|
46
|
+
If editor autocomplete looks stale, restart `yarn dev` so eddev can regenerate
|
|
47
|
+
the schema and GraphQL config from the current WordPress environment.
|
|
48
|
+
</Callout>
|
|
49
|
+
|
|
50
|
+
<img alt="GraphQL IDE" src="__img0" />
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Overview (/docs/graphql)
|
|
2
|
+
|
|
3
|
+
**Working with GraphQL in eddev**
|
|
4
|
+
|
|
5
|
+
eddev uses GraphQL as the data layer between WordPress and React. WPGraphQL exposes the schema, project `.graphql` files define exactly what data is public, and eddev generates TypeScript types and hooks from those files.
|
|
6
|
+
|
|
7
|
+
Most of the time, you write GraphQL files rather than fetch data manually.
|
|
8
|
+
|
|
9
|
+
## File Locations [#file-locations]
|
|
10
|
+
|
|
11
|
+
| Location | What It Does |
|
|
12
|
+
| -------------------------------- | ----------------------------------------------------------------------- |
|
|
13
|
+
| `views/_app.graphql` | Global app data, available through `_app.tsx` props and `useAppData()` |
|
|
14
|
+
| `views/*.graphql` | Data for the paired view, passed as view props before the route renders |
|
|
15
|
+
| `blocks/**/*.graphql` | Data for the paired block, passed as block props |
|
|
16
|
+
| `queries/fragments/**/*.graphql` | Reusable selections and generated fragment types |
|
|
17
|
+
| `queries/**/*.graphql` | Runtime query and mutation hooks generated into `hooks/queries.ts` |
|
|
18
|
+
|
|
19
|
+
<Cards>
|
|
20
|
+
<Card icon="<Lightbulb />" title="Global Data" href="/docs/graphql/global-data">
|
|
21
|
+
Fetch shared site shell data through `views/_app.graphql`.
|
|
22
|
+
</Card>
|
|
23
|
+
|
|
24
|
+
<Card icon="<Lightbulb />" title="View Data" href="/docs/views/queries">
|
|
25
|
+
Pair view templates with GraphQL files for route props.
|
|
26
|
+
</Card>
|
|
27
|
+
|
|
28
|
+
<Card icon="<Lightbulb />" title="Block Data" href="/docs/blocks/data-and-editing">
|
|
29
|
+
Select ACF and block fields before blocks render.
|
|
30
|
+
</Card>
|
|
31
|
+
|
|
32
|
+
<Card icon="<Lightbulb />" title="Fragments" href="/docs/graphql/fragments">
|
|
33
|
+
Reuse GraphQL selections and generated fragment types.
|
|
34
|
+
</Card>
|
|
35
|
+
</Cards>
|
|
36
|
+
|
|
37
|
+
## Generated Files [#generated-files]
|
|
38
|
+
|
|
39
|
+
The dev process generates:
|
|
40
|
+
|
|
41
|
+
* `types.graphql.ts` - operation, fragment, enum, scalar, and schema-derived TypeScript types
|
|
42
|
+
* `types.views.ts` - the `ViewProps` map used by `defineView`
|
|
43
|
+
* `types.blocks.ts` - the `BlockProps` map used by `defineBlock`
|
|
44
|
+
* `types.util.ts` - helper global types such as post types, page templates, block tags, and post meta types
|
|
45
|
+
* `hooks/queries.ts` - runtime query and mutation hooks for files under `queries/`
|
|
46
|
+
* `schema.json` - the local schema file used by editor tooling
|
|
47
|
+
|
|
48
|
+
These files are generated output. Do not edit them directly.
|
|
49
|
+
|
|
50
|
+
## Automatic Versus Runtime Queries [#automatic-versus-runtime-queries]
|
|
51
|
+
|
|
52
|
+
View, Block, and Global Data queries are executed as part of rendering route data. They are available before the relevant view or block renders.
|
|
53
|
+
|
|
54
|
+
Runtime hooks from `queries/*.graphql` are different. They are browser-side runtime fetches, useful for search, filters, pagination, user-triggered data loading, and mutations. They are not part of the server-rendered route payload.
|
|
55
|
+
|
|
56
|
+
<Cards>
|
|
57
|
+
<Card icon="<Lightbulb />" title="Query Hooks" href="/docs/graphql/query-hooks">
|
|
58
|
+
Fetch runtime browser data through generated TanStack Query hooks.
|
|
59
|
+
</Card>
|
|
60
|
+
|
|
61
|
+
<Card icon="<Lightbulb />" title="Infinite Queries" href="/docs/graphql/infinite-queries">
|
|
62
|
+
Build load-more interfaces on WPGraphQL cursor connections.
|
|
63
|
+
</Card>
|
|
64
|
+
|
|
65
|
+
<Card icon="<Lightbulb />" title="Mutation Hooks" href="/docs/graphql/mutation-hooks">
|
|
66
|
+
Call named runtime mutations through generated hooks.
|
|
67
|
+
</Card>
|
|
68
|
+
</Cards>
|
|
69
|
+
|
|
70
|
+
## Runtime Endpoints [#runtime-endpoints]
|
|
71
|
+
|
|
72
|
+
Runtime hooks do not send arbitrary GraphQL text to the public `/graphql` endpoint. eddev exposes named REST endpoints instead:
|
|
73
|
+
|
|
74
|
+
* `GET /wp-json/ed/v1/query/{queryName}?params={...}` for query hooks
|
|
75
|
+
* `POST /wp-json/ed/v1/mutation/{mutationName}` for mutation hooks
|
|
76
|
+
|
|
77
|
+
The `{queryName}` or `{mutationName}` maps to a file under `queries/`. For example, `queries/search/UseSearchResults.graphql` is requested by name as `search/UseSearchResults`.
|
|
78
|
+
|
|
79
|
+
This keeps public runtime access limited to query files committed in the theme, while still using WPGraphQL internally.
|
|
80
|
+
|
|
81
|
+
## Caching [#caching]
|
|
82
|
+
|
|
83
|
+
View, app, and runtime query data use the cache settings from `ed.config.json`. Individual query files can override the cache duration with a leading comment:
|
|
84
|
+
|
|
85
|
+
```graphql
|
|
86
|
+
# ttl: 300
|
|
87
|
+
query UseRecentPosts {
|
|
88
|
+
posts(first: 3) {
|
|
89
|
+
nodes {
|
|
90
|
+
title
|
|
91
|
+
uri
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use `# nocache` when a query should never be cached.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Colour Schemes (/docs/guides/color-schemes)
|
|
2
|
+
|
|
3
|
+
**Define named visual schemes with Tailwind semantic tokens.**
|
|
4
|
+
|
|
5
|
+
Use colour schemes when a section, card, page, or route needs to switch the
|
|
6
|
+
same component between named visual themes. The Tailwind helper implements this
|
|
7
|
+
with `subthemes`: a scheme class changes semantic CSS variables, while
|
|
8
|
+
component code keeps using `bg-bg`, `text-fg`, `border-bg-low`, and similar
|
|
9
|
+
semantic classes.
|
|
10
|
+
|
|
11
|
+
## Define Schemes [#define-schemes]
|
|
12
|
+
|
|
13
|
+
Define the possible scheme classes in `tailwind.config.ts`.
|
|
14
|
+
|
|
15
|
+
```ts filename="tailwind.config.ts"
|
|
16
|
+
responsiveTheme({
|
|
17
|
+
colors: {
|
|
18
|
+
base: {
|
|
19
|
+
black: "#202020",
|
|
20
|
+
white: "#ffffff",
|
|
21
|
+
silver: {
|
|
22
|
+
DEFAULT: "#d8d8d8",
|
|
23
|
+
light: "#f1f1f1",
|
|
24
|
+
dark: "#aaaaaa",
|
|
25
|
+
},
|
|
26
|
+
orange: "#ea5e42",
|
|
27
|
+
blue: "#2f99d4",
|
|
28
|
+
green: "#4a9f62",
|
|
29
|
+
card: "#dec99c",
|
|
30
|
+
yellow: "#f8d44f",
|
|
31
|
+
},
|
|
32
|
+
semantic: {
|
|
33
|
+
bg: "silver.light",
|
|
34
|
+
fg: "black",
|
|
35
|
+
"bg-low": "silver",
|
|
36
|
+
},
|
|
37
|
+
subthemes: {
|
|
38
|
+
"theme-black": {
|
|
39
|
+
bg: "black",
|
|
40
|
+
fg: "silver.light",
|
|
41
|
+
"bg-low": "silver.dark",
|
|
42
|
+
},
|
|
43
|
+
"theme-orange": {
|
|
44
|
+
bg: "orange",
|
|
45
|
+
fg: "black",
|
|
46
|
+
"bg-low": "white",
|
|
47
|
+
},
|
|
48
|
+
"theme-blue": {
|
|
49
|
+
bg: "blue",
|
|
50
|
+
fg: "black",
|
|
51
|
+
"bg-low": "white",
|
|
52
|
+
},
|
|
53
|
+
"theme-green": {
|
|
54
|
+
bg: "green",
|
|
55
|
+
fg: "black",
|
|
56
|
+
"bg-low": "white",
|
|
57
|
+
},
|
|
58
|
+
"theme-card": {
|
|
59
|
+
bg: "card",
|
|
60
|
+
fg: "black",
|
|
61
|
+
"bg-low": "white",
|
|
62
|
+
},
|
|
63
|
+
"theme-yellow": {
|
|
64
|
+
bg: "yellow",
|
|
65
|
+
fg: "black",
|
|
66
|
+
"bg-low": "white",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The key is the class name. Use a `theme-*` prefix for scheme classes unless a
|
|
74
|
+
project has already established different naming.
|
|
75
|
+
|
|
76
|
+
## Apply A Scheme [#apply-a-scheme]
|
|
77
|
+
|
|
78
|
+
Apply the class at the smallest useful boundary. A whole page can set a scheme:
|
|
79
|
+
|
|
80
|
+
```tsx filename="views/single-case-study.tsx"
|
|
81
|
+
import { pageColorClass } from "@features/brand/usePageColor"
|
|
82
|
+
import { cn } from "@utils/tw"
|
|
83
|
+
import { defineView } from "eddev/views"
|
|
84
|
+
|
|
85
|
+
export default defineView("single-case-study", (props) => {
|
|
86
|
+
return (
|
|
87
|
+
<div className={cn(pageColorClass(props.caseStudy?.info?.pageColor))}>
|
|
88
|
+
<SubpageContentBlocks blocks={props.caseStudy?.contentBlocks} />
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A single block or card can set its own scheme:
|
|
95
|
+
|
|
96
|
+
```tsx filename="components/Card.tsx"
|
|
97
|
+
const SCHEME_CLASSES = {
|
|
98
|
+
black: "theme-black",
|
|
99
|
+
orange: "theme-orange",
|
|
100
|
+
blue: "theme-blue",
|
|
101
|
+
} as const
|
|
102
|
+
|
|
103
|
+
export function Card(props: {
|
|
104
|
+
color?: keyof typeof SCHEME_CLASSES
|
|
105
|
+
children: React.ReactNode
|
|
106
|
+
}) {
|
|
107
|
+
return (
|
|
108
|
+
<article className={`${SCHEME_CLASSES[props.color ?? "black"]} bg-bg text-fg p-4 rounded-md`}>
|
|
109
|
+
{props.children}
|
|
110
|
+
</article>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Use generated variants when a component needs to adjust itself based on an
|
|
116
|
+
ancestor theme:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<div className="bg-orange text-fg is-theme-black:theme-orange">
|
|
120
|
+
...
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The helper creates `is-${themeName}:` variants for every configured subtheme.
|
|
125
|
+
|
|
126
|
+
## Let Editors Choose [#let-editors-choose]
|
|
127
|
+
|
|
128
|
+
For editor-controlled schemes, register a small enum field in PHP and select it
|
|
129
|
+
in the block or view GraphQL file.
|
|
130
|
+
|
|
131
|
+
```php filename="backend/fields/page-scheme.php"
|
|
132
|
+
<?php
|
|
133
|
+
|
|
134
|
+
ED()->registerEnumFieldType("page-scheme", [
|
|
135
|
+
"label" => "Page Scheme",
|
|
136
|
+
"type" => "select",
|
|
137
|
+
"allow_null" => 1,
|
|
138
|
+
"options" => [
|
|
139
|
+
"silver" => "Silver",
|
|
140
|
+
"green" => "Green",
|
|
141
|
+
"orange" => "Orange",
|
|
142
|
+
"blue" => "Blue",
|
|
143
|
+
"card" => "Card",
|
|
144
|
+
"yellow" => "Yellow",
|
|
145
|
+
],
|
|
146
|
+
]);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```graphql filename="blocks/pages/highlight-section.graphql"
|
|
150
|
+
query {
|
|
151
|
+
block {
|
|
152
|
+
pages_highlight_section {
|
|
153
|
+
theme
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Map the generated enum values to classes in one helper:
|
|
160
|
+
|
|
161
|
+
```tsx filename="features/brand/pageColor.ts"
|
|
162
|
+
import { PageSchemeOption, SectionSchemeOption } from "@generated-types"
|
|
163
|
+
|
|
164
|
+
const SCHEME_CLASSES: Record<PageSchemeOption, string> = {
|
|
165
|
+
silver: "theme-silver",
|
|
166
|
+
green: "theme-green",
|
|
167
|
+
orange: "theme-orange",
|
|
168
|
+
blue: "theme-blue",
|
|
169
|
+
card: "theme-card",
|
|
170
|
+
yellow: "theme-yellow",
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function pageColorClass(
|
|
174
|
+
color: PageSchemeOption | SectionSchemeOption | null | undefined,
|
|
175
|
+
) {
|
|
176
|
+
return SCHEME_CLASSES[color || "silver"] || SCHEME_CLASSES.silver
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Keep the enum small. Most projects only need page-level schemes and a shorter
|
|
181
|
+
section-level set for blocks.
|
|
182
|
+
|
|
183
|
+
## Route-Level Themes [#route-level-themes]
|
|
184
|
+
|
|
185
|
+
For route-driven themes, derive the current theme from `RouteState` and apply
|
|
186
|
+
the scheme around `RouteDisplay`.
|
|
187
|
+
|
|
188
|
+
```tsx filename="features/routes/ThemedRouteDisplay.tsx"
|
|
189
|
+
import { RouteDisplay, RouteState } from "eddev/routing"
|
|
190
|
+
|
|
191
|
+
export function ThemedRouteDisplay(props: { route: RouteState }) {
|
|
192
|
+
const dark = props.route.view === "template-home"
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<div className={dark ? "theme-dark bg-bg text-fg" : "theme-light bg-bg text-fg"}>
|
|
196
|
+
<RouteDisplay route={props.route} />
|
|
197
|
+
</div>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Use route-level themes for global surfaces such as headers, drawers, page
|
|
203
|
+
transitions, and footers. Use block fields for author-controlled content
|
|
204
|
+
sections.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Deployment (/docs/infra/deployment)
|
|
2
|
+
|
|
3
|
+
**A placeholder for deployment workflows across GitHub, Vercel, and Cloudflare.**
|
|
4
|
+
|
|
5
|
+
TODO: Overview of Github actions, Vercel, CloudFlare
|
|
6
|
+
|
|
7
|
+
## Github Actions [#github-actions]
|
|
8
|
+
|
|
9
|
+
TODO: Github actions info
|
|
10
|
+
|
|
11
|
+
## Vercel [#vercel]
|
|
12
|
+
|
|
13
|
+
TODO: Vercel deployment info for serverless
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Security (/docs/infra/security)
|
|
2
|
+
|
|
3
|
+
**A placeholder for origin protection and secret management guidance.**
|
|
4
|
+
|
|
5
|
+
## Preventing WordPress Access [#preventing-wordpress-access]
|
|
6
|
+
|
|
7
|
+
TODO: Section on using `SITE_API_KEY` and password protection to prevent public access to the WordPress server.
|
|
8
|
+
|
|
9
|
+
## Environment Variables [#environment-variables]
|
|
10
|
+
|
|
11
|
+
TODO: Section on local + production secret management
|