@stackables/bridge 1.4.0 → 1.4.1
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/README.md +81 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[](https://github.com/stackables/bridge)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# The Bridge
|
|
5
|
+
|
|
6
|
+
**Declarative dataflow for GraphQL.**
|
|
7
|
+
Wire data between APIs, tools, and fields using `.bridge` files—no resolvers, no codegen, no plumbing.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @stackables/bridge
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## The Workflow
|
|
15
|
+
|
|
16
|
+
The Bridge doesn't replace your GraphQL schema; it implements it. You define your **Types** in standard GraphQL SDL, then use `.bridge` files to wire those types to your data sources.
|
|
17
|
+
|
|
18
|
+
### 1. Define your Schema
|
|
19
|
+
|
|
20
|
+
Start with a standard `schema.graphql` file. This is your "Interface."
|
|
21
|
+
|
|
22
|
+
```graphql
|
|
23
|
+
type Location {
|
|
24
|
+
lat: Float
|
|
25
|
+
lon: Float
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type Query {
|
|
29
|
+
location(city: String!): Location
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Wire the Bridge
|
|
35
|
+
|
|
36
|
+
Create your `logic.bridge` file to implement the resolver for that specific field. This is your "Implementation."
|
|
37
|
+
|
|
38
|
+
```hcl
|
|
39
|
+
version 1.4
|
|
40
|
+
|
|
41
|
+
tool geo from httpCall {
|
|
42
|
+
.baseUrl = "https://nominatim.openstreetmap.org"
|
|
43
|
+
.path = "/search"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
bridge Query.location {
|
|
47
|
+
with geo
|
|
48
|
+
with input as i
|
|
49
|
+
with output as o
|
|
50
|
+
|
|
51
|
+
# 'i.city' comes from the GraphQL argument
|
|
52
|
+
# 'o.lat' maps to the 'lat' field in the Location type
|
|
53
|
+
geo.q <- i.city
|
|
54
|
+
o.lat <- geo[0].lat
|
|
55
|
+
o.lon <- geo[0].lon
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Initialize the Engine
|
|
60
|
+
|
|
61
|
+
The Bridge takes your existing schema and automatically attaches the logic.
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { bridgeTransform, parseBridge } from "@stackables/bridge";
|
|
65
|
+
import { createSchema } from "graphql-yoga";
|
|
66
|
+
|
|
67
|
+
const typeDefs = /* load your schema.graphql */;
|
|
68
|
+
const bridgeFile = /* load your logic.bridge */;
|
|
69
|
+
|
|
70
|
+
const schema = bridgeTransform(
|
|
71
|
+
createSchema({ typeDefs }),
|
|
72
|
+
parseBridge(bridgeFile)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## The Language
|
|
80
|
+
|
|
81
|
+
https://github.com/stackables/bridge
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackables/bridge",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Declarative dataflow for GraphQL",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./src/index.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"build"
|
|
9
|
+
"build",
|
|
10
|
+
"README.md"
|
|
10
11
|
],
|
|
11
12
|
"scripts": {
|
|
12
13
|
"build": "tsc -p tsconfig.json",
|