b-gsdk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +32 -0
- package/package.json +34 -0
- package/src/docs/fragments/product.gql +10 -0
- package/src/index.ts +56 -0
- package/tsconfig.json +21 -0
package/dist/index.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
|
19
|
+
// src/index.ts
|
20
|
+
var src_exports = {};
|
21
|
+
__export(src_exports, {
|
22
|
+
helloWorld: () => helloWorld
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(src_exports);
|
25
|
+
var hey = "hola mundo";
|
26
|
+
function helloWorld() {
|
27
|
+
return hey + "ma";
|
28
|
+
}
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
30
|
+
0 && (module.exports = {
|
31
|
+
helloWorld
|
32
|
+
});
|
package/package.json
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"name": "b-gsdk",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "A GraphQL Codegen that outputs a TypeScript SDK.",
|
5
|
+
"author": "Julian Benegas",
|
6
|
+
"license": "MIT",
|
7
|
+
"dependencies": {
|
8
|
+
"@graphql-codegen/cli": "^2.6.2",
|
9
|
+
"@graphql-codegen/core": "^2.5.1",
|
10
|
+
"@graphql-codegen/introspection": "^2.1.0",
|
11
|
+
"@graphql-codegen/typescript": "^2.4.1",
|
12
|
+
"@graphql-codegen/typescript-graphql-request": "^4.3.2",
|
13
|
+
"@graphql-codegen/typescript-operations": "^2.2.1",
|
14
|
+
"resolve-pkg": "^2.0.0"
|
15
|
+
},
|
16
|
+
"peerDependencies": {
|
17
|
+
"graphql": "*",
|
18
|
+
"graphql-request": "*",
|
19
|
+
"graphql-tag": "*"
|
20
|
+
},
|
21
|
+
"devDependencies": {
|
22
|
+
"@tsconfig/node16": "^1.0.2",
|
23
|
+
"@types/node": "^17.0.24",
|
24
|
+
"esbuild": "^0.14.36",
|
25
|
+
"graphql": "^16.3.0",
|
26
|
+
"ts-node": "^10.7.0",
|
27
|
+
"typescript": "^4.6.3"
|
28
|
+
},
|
29
|
+
"scripts": {
|
30
|
+
"build": "esbuild ./src/index.ts --bundle --platform=node --target=node16 --outdir=dist",
|
31
|
+
"watch": "yarn build --watch",
|
32
|
+
"generate": "ts-node ./src/index.ts"
|
33
|
+
}
|
34
|
+
}
|
package/src/index.ts
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
import { generate } from "@graphql-codegen/cli";
|
2
|
+
import resolvePkg from "resolve-pkg";
|
3
|
+
import fs from "fs";
|
4
|
+
import path from "path";
|
5
|
+
|
6
|
+
async function main() {
|
7
|
+
const [schemaCodegen, sdkCodegen] = await generate(
|
8
|
+
{
|
9
|
+
schema: {
|
10
|
+
"https://mr-beast-2.myshopify.com/api/2021-10/graphql": {
|
11
|
+
headers: {
|
12
|
+
"x-shopify-storefront-access-token":
|
13
|
+
"374a3639228aeb7798d99d88002c4b2e",
|
14
|
+
},
|
15
|
+
},
|
16
|
+
},
|
17
|
+
generates: {
|
18
|
+
[__dirname + "/generated/index.ts"]: {
|
19
|
+
documents: [
|
20
|
+
__dirname + "/docs/**/*.{gql,graphql}",
|
21
|
+
__dirname + "/docs/*.{gql,graphql}",
|
22
|
+
],
|
23
|
+
plugins: [
|
24
|
+
"typescript",
|
25
|
+
"typescript-operations",
|
26
|
+
"typescript-graphql-request",
|
27
|
+
],
|
28
|
+
},
|
29
|
+
[__dirname + "/generated/graphql.schema.json"]: {
|
30
|
+
plugins: ["introspection"],
|
31
|
+
config: {
|
32
|
+
documentMode: "documentNode",
|
33
|
+
withHooks: true,
|
34
|
+
},
|
35
|
+
},
|
36
|
+
},
|
37
|
+
},
|
38
|
+
false
|
39
|
+
);
|
40
|
+
const resolved = resolvePkg("@b-gsdk/client");
|
41
|
+
if (!resolved) {
|
42
|
+
console.error("Please install @b-gsdk/client");
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
fs.writeFileSync(
|
46
|
+
path.join(resolved, "generated/graphql.schema.json"),
|
47
|
+
schemaCodegen.content
|
48
|
+
);
|
49
|
+
fs.writeFileSync(
|
50
|
+
path.join(resolved, "generated/index.ts"),
|
51
|
+
sdkCodegen.content
|
52
|
+
);
|
53
|
+
console.log("done");
|
54
|
+
}
|
55
|
+
|
56
|
+
main();
|
package/tsconfig.json
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"extends": "@tsconfig/node16/tsconfig.json",
|
3
|
+
|
4
|
+
// Most ts-node options can be specified here using their programmatic names.
|
5
|
+
"ts-node": {
|
6
|
+
// It is faster to skip typechecking.
|
7
|
+
// Remove if you want ts-node to do typechecking.
|
8
|
+
"transpileOnly": true,
|
9
|
+
|
10
|
+
"files": true,
|
11
|
+
|
12
|
+
"compilerOptions": {
|
13
|
+
// compilerOptions specified here will override those declared below,
|
14
|
+
// but *only* in ts-node. Useful if you want ts-node and tsc to use
|
15
|
+
// different options with a single tsconfig.json.
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"compilerOptions": {
|
19
|
+
// typescript options here
|
20
|
+
}
|
21
|
+
}
|