-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improve
docs/reference/types
(#685)
Improves `docs/reference/types` #### Motivation and context _N/A_ #### Migration notes _N/A_ ### Checklist - [ ] The change come with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [x] End-user documentation is updated to reflect the change --------- Signed-off-by: Michaël <afmichael73@gmail.com> Co-authored-by: afmika <afmichael73@gmail.com> Co-authored-by: Teo Stocco <teo@zifeo.com> Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>
- Loading branch information
1 parent
f0f41ac
commit 774fe3d
Showing
37 changed files
with
550 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typegraph import Policy, typegraph, t, Graph | ||
from typegraph.runtimes.deno import DenoRuntime | ||
|
||
|
||
@typegraph() | ||
def injection_example(g: Graph): | ||
deno = DenoRuntime() | ||
pub = Policy.public() | ||
|
||
g.expose( | ||
get_injected=deno.func( | ||
t.struct( | ||
{ | ||
"static_value": t.integer().set(12), | ||
"context_value": t.uuid().from_context("profile.userId"), | ||
"secret_value": t.string().from_secret("secret_name"), | ||
"dynamic_value": t.datetime().inject("now"), | ||
} | ||
).rename("Input"), | ||
t.struct( | ||
{ | ||
"static_value": t.integer().rename("Static"), | ||
"context_value": t.uuid(), | ||
"secret_value": t.string(), | ||
"nested": deno.identity( | ||
t.struct({"parent_value": t.integer().from_parent("Static")}), | ||
), | ||
"dynamic_value": t.datetime(), | ||
} | ||
).rename("Output"), | ||
code=""" | ||
({ static_value, context_value, secret_value, dynamic_value }) => ({ static_value, context_value, secret_value, dynamic_value }) | ||
""", | ||
).with_policy(pub) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Policy, t, typegraph } from "@typegraph/sdk"; | ||
import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; | ||
|
||
typegraph("injection-example", (g) => { | ||
const deno = new DenoRuntime(); | ||
const pub = Policy.public(); | ||
|
||
g.expose({ | ||
get_injected: deno.func( | ||
t.struct({ | ||
static_value: t.integer().set(12), | ||
context_value: t.uuid().fromContext("profile.userId"), | ||
secret_value: t.string().fromSecret("secret_name"), | ||
dynamic_value: t.datetime().inject("now"), | ||
}).rename("Input"), | ||
t.struct({ | ||
static_value: t.integer().rename("Static"), | ||
context_value: t.uuid(), | ||
secret_value: t.string(), | ||
nested: deno.identity( | ||
t.struct({ | ||
parent_value: t.integer().fromParent("Static"), | ||
}), | ||
), | ||
dynamic_value: t.datetime(), | ||
}).rename("Output"), | ||
{ | ||
code: ( | ||
{ static_value, context_value, secret_value, dynamic_value }, | ||
) => ({ static_value, context_value, secret_value, dynamic_value }), | ||
}, | ||
).withPolicy(pub), | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.