From a48682b92897127a298affadd7a1fde6971fb4a5 Mon Sep 17 00:00:00 2001 From: destifo Date: Sat, 1 Jun 2024 03:28:31 +0300 Subject: [PATCH 1/4] fix: attempt to fix missing typegraphs --- examples/typegraphs/http-runtime.ts | 50 +++++++++++++++++++ .../docs/concepts/features-overview/index.mdx | 2 +- website/docs/concepts/mental-model/index.mdx | 4 +- .../docs/reference/runtimes/deno/index.mdx | 2 +- .../docs/reference/runtimes/http/index.mdx | 1 + .../docs/reference/runtimes/random/index.mdx | 2 +- .../runtimes/random/random-field.graphql | 10 ++-- .../typegate/synchronization/index.mdx | 2 +- .../docs/tutorials/metatype-basics/index.mdx | 14 +++--- 9 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 examples/typegraphs/http-runtime.ts diff --git a/examples/typegraphs/http-runtime.ts b/examples/typegraphs/http-runtime.ts new file mode 100644 index 0000000000..b9e96f40c0 --- /dev/null +++ b/examples/typegraphs/http-runtime.ts @@ -0,0 +1,50 @@ +// skip:start +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; + +// isort: off +// skip:end +// highlight-next-line +import { HttpRuntime } from "@typegraph/sdk/runtimes/http.js"; + +await typegraph( + { + name: "http-runtime-ts", + // skip:next-line + cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] }, + }, + (g) => { + // highlight-next-line + const facts = new HttpRuntime("https://uselessfacts.jsph.pl/api/v2/facts"); + const pub = Policy.public(); + + g.expose( + { + facts: facts.get( + t.struct({ + language: t.enum_(["en", "de"]), + }), + t.struct({ + id: t.string(), + text: t.string(), + source: t.string(), + source_url: t.string(), + language: t.string(), + permalink: t.string(), + }), + { + path: "/random", + } + ), + facts_as_text: facts.get( + t.struct({ + header_accept: t.string().set("text/explain"), + language: t.enum_(["en", "de"]), + }), + t.string(), + { path: "/random", headerPrefix: "header_" } + ), + }, + pub + ); + } +); diff --git a/website/docs/concepts/features-overview/index.mdx b/website/docs/concepts/features-overview/index.mdx index 4e8f9bbfa1..fc4b1b4d82 100644 --- a/website/docs/concepts/features-overview/index.mdx +++ b/website/docs/concepts/features-overview/index.mdx @@ -146,7 +146,7 @@ We're taking any and all kinds of feature requests, suggestions and recommendati rows={[ [ , diff --git a/website/docs/concepts/mental-model/index.mdx b/website/docs/concepts/mental-model/index.mdx index 2a33aad169..5d84030d86 100644 --- a/website/docs/concepts/mental-model/index.mdx +++ b/website/docs/concepts/mental-model/index.mdx @@ -55,7 +55,7 @@ This computing model brings numerous advantages: **Types** are the building block of typegraphs. They define a type system describing all data objects processed in Metatype. They can be easily extended to support new data types according to the needs of the application. - {require("../../../../examples/typegraphs/types.py").content} + {require("!!code-loader!../../../../examples/typegraphs/types.py").content} **Analogy in SQL**: types are similar to the Data Definition Language (DDL) with the extended capacity of describing any type of data. @@ -101,7 +101,7 @@ The policy decision can be: Triggers are events launching the execution of one or multiple functions. They fire when a GraphQL request is received for the specific typegraph. - {require("../../../../examples/typegraphs/triggers.py").content} + {require("!!code-loader!../../../../examples/typegraphs/triggers.py").content} **Analogy in SQL**: a trigger is similar to receiving a new query. diff --git a/website/docs/reference/runtimes/deno/index.mdx b/website/docs/reference/runtimes/deno/index.mdx index 03e79482c0..783564cace 100644 --- a/website/docs/reference/runtimes/deno/index.mdx +++ b/website/docs/reference/runtimes/deno/index.mdx @@ -11,8 +11,8 @@ The DenoRuntime allows you to run lightweight and short-lived typescript functio diff --git a/website/docs/reference/runtimes/http/index.mdx b/website/docs/reference/runtimes/http/index.mdx index b9a41e9a3f..9d0a902b3c 100644 --- a/website/docs/reference/runtimes/http/index.mdx +++ b/website/docs/reference/runtimes/http/index.mdx @@ -14,6 +14,7 @@ Common use cases (but not limited to): Example: diff --git a/website/docs/reference/runtimes/random/index.mdx b/website/docs/reference/runtimes/random/index.mdx index 30b20bee87..9075606af2 100644 --- a/website/docs/reference/runtimes/random/index.mdx +++ b/website/docs/reference/runtimes/random/index.mdx @@ -24,7 +24,7 @@ The `seed` parameter ensures repeatability if set. Another use case is to inject random values to a function input diff --git a/website/docs/reference/runtimes/random/random-field.graphql b/website/docs/reference/runtimes/random/random-field.graphql index b4f0e77241..54686d8334 100644 --- a/website/docs/reference/runtimes/random/random-field.graphql +++ b/website/docs/reference/runtimes/random/random-field.graphql @@ -1,4 +1,8 @@ query { - bonus1: get_bonus(performance: 200) - bonus2: get_bonus(performance: 27) -} \ No newline at end of file + bonus1: get_bonus( + performance: 200 + ) + bonus2: get_bonus( + performance: 27 + ) +} diff --git a/website/docs/reference/typegate/synchronization/index.mdx b/website/docs/reference/typegate/synchronization/index.mdx index 1b92715ee6..75a3c31ae6 100644 --- a/website/docs/reference/typegate/synchronization/index.mdx +++ b/website/docs/reference/typegate/synchronization/index.mdx @@ -5,7 +5,7 @@ The typegate run in either on of the following modes: - _Single instance mode:_ a single typegate instance runs all the workloads; -- _Synchronized mode:_ the workloads can be shared accross multiple typegraph instances. +- _Synchronized mode:_ the workloads can be shared accross multiple typegate instances. ## System setup diff --git a/website/docs/tutorials/metatype-basics/index.mdx b/website/docs/tutorials/metatype-basics/index.mdx index 3603e5bb93..aa25f2f81d 100644 --- a/website/docs/tutorials/metatype-basics/index.mdx +++ b/website/docs/tutorials/metatype-basics/index.mdx @@ -14,7 +14,7 @@ import CodeBlock from "@theme-original/CodeBlock"; :::note You will learn - How to setup your development for metatype projects. -- How to run the typegate on the docker runtime. +- How to run the typegate onf the docker runtime. - How to create/read/update/delete data. - How to write custom business logic. - How to authenticate requests. @@ -322,7 +322,7 @@ Or, you can mess around on the playground below. @@ -576,7 +576,7 @@ We should be able to add a few buckets and ideas now. @@ -691,8 +691,8 @@ If you are using the GraphiQl interface from earlier, there should be a panel in @@ -830,7 +830,7 @@ mutation { @@ -913,7 +913,7 @@ Our query is exposed like any other function in the GraphQl api. From 5e773d30c4f1a4810a38955afd9e3d919d5154db Mon Sep 17 00:00:00 2001 From: destifo Date: Sat, 1 Jun 2024 10:38:08 +0300 Subject: [PATCH 2/4] chore: update typegraph example name --- examples/typegraphs/http-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typegraphs/http-runtime.ts b/examples/typegraphs/http-runtime.ts index b9e96f40c0..13e6a80bc6 100644 --- a/examples/typegraphs/http-runtime.ts +++ b/examples/typegraphs/http-runtime.ts @@ -8,7 +8,7 @@ import { HttpRuntime } from "@typegraph/sdk/runtimes/http.js"; await typegraph( { - name: "http-runtime-ts", + name: "http-example", // skip:next-line cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] }, }, From c9c639cf0d59b326b433e2a0dc51eaf98e1a2fa8 Mon Sep 17 00:00:00 2001 From: destifo Date: Sat, 1 Jun 2024 11:26:51 +0300 Subject: [PATCH 3/4] chore: fix typegraph mismatch --- examples/typegraphs/http-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typegraphs/http-runtime.ts b/examples/typegraphs/http-runtime.ts index 13e6a80bc6..ec788fbfac 100644 --- a/examples/typegraphs/http-runtime.ts +++ b/examples/typegraphs/http-runtime.ts @@ -37,7 +37,7 @@ await typegraph( ), facts_as_text: facts.get( t.struct({ - header_accept: t.string().set("text/explain"), + header_accept: t.string().set("text/plain"), language: t.enum_(["en", "de"]), }), t.string(), From 11e4c294e4493d41a520541886863c0c2242a845 Mon Sep 17 00:00:00 2001 From: destifo Date: Sat, 1 Jun 2024 13:33:11 +0300 Subject: [PATCH 4/4] chore: fix typo --- website/docs/tutorials/metatype-basics/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/tutorials/metatype-basics/index.mdx b/website/docs/tutorials/metatype-basics/index.mdx index aa25f2f81d..8c70b9e940 100644 --- a/website/docs/tutorials/metatype-basics/index.mdx +++ b/website/docs/tutorials/metatype-basics/index.mdx @@ -14,7 +14,7 @@ import CodeBlock from "@theme-original/CodeBlock"; :::note You will learn - How to setup your development for metatype projects. -- How to run the typegate onf the docker runtime. +- How to run the typegate on the docker runtime. - How to create/read/update/delete data. - How to write custom business logic. - How to authenticate requests.