@baeta/util-graphql 0.0.0 → 2.0.0-next.2
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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +184 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @baeta/util-graphql
|
|
2
|
+
|
|
3
|
+
## 2.0.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#389](https://github.com/andreisergiu98/baeta/pull/389) [`3e7a4d7`](https://github.com/andreisergiu98/baeta/commit/3e7a4d71a59543b8a506938f788aec8b5d907776) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Extract graphql utilities into @baeta/util-graphql
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3e7a4d7`](https://github.com/andreisergiu98/baeta/commit/3e7a4d71a59543b8a506938f788aec8b5d907776), [`53322ca`](https://github.com/andreisergiu98/baeta/commit/53322ca8ad0c10bce70e49692d5d15023ec3a5e8)]:
|
|
10
|
+
- @baeta/util-path@2.0.0-next.4
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Pampu Andrei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/andreisergiu98/baeta/refs/heads/main/website/static/img/logo-baeta.svg" alt="Baeta Logo" width="150"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h1>Baeta</h1>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@baeta/cli"><img src="https://img.shields.io/npm/v/@baeta/cli.svg?style=flat" /></a>
|
|
8
|
+
<a href="https://github.com/andreisergiu98/baeta/actions/workflows/checks.yml"><img src="https://img.shields.io/github/actions/workflow/status/andreisergiu98/baeta/checks.yml" /></a>
|
|
9
|
+
<a href="https://github.com/andreisergiu98/baeta/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" /></a>
|
|
10
|
+
<a href="https://github.com/andreisergiu98/baeta/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
|
11
|
+
<br />
|
|
12
|
+
<br />
|
|
13
|
+
<a href="https://baeta.io/docs/getting-started/installation">Getting Started</a>
|
|
14
|
+
<span> • </span>
|
|
15
|
+
<a href="https://www.baeta.io/">Website</a>
|
|
16
|
+
<span> • </span>
|
|
17
|
+
<a href="https://baeta.io/docs/intro">Docs</a>
|
|
18
|
+
<span> • </span>
|
|
19
|
+
<a href="https://github.com/andreisergiu98/baeta/tree/main/examples">Examples</a>
|
|
20
|
+
<span> • </span>
|
|
21
|
+
<a href="https://discord.gg/BHFXHvyj">Discord</a>
|
|
22
|
+
<br />
|
|
23
|
+
<hr />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
# What is Baeta?
|
|
27
|
+
|
|
28
|
+
Building GraphQL APIs shouldn't be complicated. **Baeta** is a modern, modular, open-source GraphQL framework designed with flexibility in mind. It follows a granular approach where you only add what you need, helping developers focus on what matters most - creating powerful, scalable APIs without the boilerplate.
|
|
29
|
+
|
|
30
|
+
### Key Features
|
|
31
|
+
|
|
32
|
+
- **Modular Architecture**: Organize your API into manageable modules
|
|
33
|
+
- **Schema-First Development**: Define your API contract upfront
|
|
34
|
+
- **Type Safety**: Automatic code generation for type-safe development
|
|
35
|
+
- **Middleware & Directives**: Easy integration of custom behaviors
|
|
36
|
+
- **High Performance**: Built for scalability and efficiency
|
|
37
|
+
|
|
38
|
+
#### And optional extensions and plugins
|
|
39
|
+
|
|
40
|
+
- **@baeta/extension-auth**: Add powerful scope-based authorization
|
|
41
|
+
- **@baeta/extension-cache**: Implement automatic caching with simple update patterns
|
|
42
|
+
- ... and more!
|
|
43
|
+
|
|
44
|
+
## Why use Baeta?
|
|
45
|
+
|
|
46
|
+
Baeta makes it easy to build better GraphQL APIs while staying flexible. Here's how:
|
|
47
|
+
|
|
48
|
+
**Granular and Progressive:** Start small and add features as you need them. Whether you're building a simple API or a complex system, Baeta scales with your needs.
|
|
49
|
+
|
|
50
|
+
**Modular architecture:** Baeta's modular design allows you to organize your GraphQL API into smaller, more manageable modules that can be added or removed as needed. This makes it easier to maintain and scale your API over time.
|
|
51
|
+
|
|
52
|
+
**Schema-first approach:** With Baeta, you define your schema first, and then logic and resolvers. This approach ensures a consistent and well-defined API for your clients and reduces boilerplate code.
|
|
53
|
+
|
|
54
|
+
## How it Works
|
|
55
|
+
|
|
56
|
+
#### 1. Define your schema
|
|
57
|
+
|
|
58
|
+
```graphql
|
|
59
|
+
type User {
|
|
60
|
+
id: ID!
|
|
61
|
+
name: String!
|
|
62
|
+
email: String!
|
|
63
|
+
age: Int
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
input UserWhereUnique {
|
|
67
|
+
id: ID
|
|
68
|
+
email: String
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type Query {
|
|
72
|
+
user(where: UserWhereUnique!): User!
|
|
73
|
+
users: [User!]!
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### 2. Implement your resolvers
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { UserModule } from "./typedef.ts";
|
|
81
|
+
|
|
82
|
+
const { Query } = UserModule;
|
|
83
|
+
|
|
84
|
+
const userQuery = Query.user.resolve(({ args }) => {
|
|
85
|
+
return dataSource.user.find(args.where);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const usersQuery = Query.users.resolve(() => {
|
|
89
|
+
return dataSource.user.findMany();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
Query.$fields({
|
|
93
|
+
user: userQuery,
|
|
94
|
+
users: usersQuery,
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### 3. Add authorization
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { UserModule } from "./typedef.ts";
|
|
102
|
+
|
|
103
|
+
const { Query } = UserModule;
|
|
104
|
+
|
|
105
|
+
const userQuery = Query.user
|
|
106
|
+
.$auth({
|
|
107
|
+
$or: {
|
|
108
|
+
isPublic: true,
|
|
109
|
+
isLoggedIn: true,
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
.resolve(async ({ args }) => {
|
|
113
|
+
// ...
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### 4. Add caching
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const { Query, Mutation, User } = UserModule;
|
|
121
|
+
|
|
122
|
+
export const userCache = User.$createCache();
|
|
123
|
+
|
|
124
|
+
const userQuery = Query.user
|
|
125
|
+
.$auth({
|
|
126
|
+
// ...
|
|
127
|
+
})
|
|
128
|
+
.$useCache(userCache)
|
|
129
|
+
.resolve(async ({ args }) => {
|
|
130
|
+
// ...
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const updateUserMutation = Mutation.updateUser
|
|
134
|
+
.$use(async (next) => {
|
|
135
|
+
const user = await next();
|
|
136
|
+
await userCache.save(user);
|
|
137
|
+
return user;
|
|
138
|
+
})
|
|
139
|
+
.resolve(async ({ args }) => {
|
|
140
|
+
// ...
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Compatibility
|
|
145
|
+
|
|
146
|
+
Baeta is compatible with all GraphQL servers, which makes it easy to integrate with your existing stack. It works seamlessly with popular GraphQL server libraries such as **Graphql Yoga** and **Apollo Server**, as well as other popular tools like **Prisma**, **Drizzle** and **Kysely**.
|
|
147
|
+
|
|
148
|
+
Baeta's development tools are built for Node.js, but the runtime code is environment-agnostic. This means your Baeta applications can run anywhere JavaScript runs, including:
|
|
149
|
+
|
|
150
|
+
- Deno
|
|
151
|
+
- Cloudflare Workers
|
|
152
|
+
- AWS Lambda
|
|
153
|
+
- Vercel Edge Functions
|
|
154
|
+
- Bun
|
|
155
|
+
- Node.js
|
|
156
|
+
- Any other JavaScript runtime
|
|
157
|
+
|
|
158
|
+
## Credits
|
|
159
|
+
|
|
160
|
+
Baeta was inspired by several amazing projects and people in the GraphQL ecosystem. Check out our [Credits page](https://baeta.io/docs/credits) to learn more about the individuals and projects that influenced Baeta's development.
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
Baeta is licensed under the [MIT License](./LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as _$graphql from "graphql";
|
|
2
|
+
import { DocumentNode, EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, ObjectTypeDefinitionNode, ScalarTypeDefinitionNode, UnionTypeDefinitionNode } from "graphql";
|
|
3
|
+
import { BaseLoaderOptions, Loader, Source, Source as Source$1 } from "@graphql-tools/utils";
|
|
4
|
+
|
|
5
|
+
//#region lib/definitions-map.d.ts
|
|
6
|
+
type DefinitionsMap = ReturnType<typeof createRegistry>;
|
|
7
|
+
declare function createRegistry(): {
|
|
8
|
+
scalarTypeMap: Map<string, ScalarTypeDefinitionNode>;
|
|
9
|
+
enumTypeMap: Map<string, EnumTypeDefinitionNode>;
|
|
10
|
+
objectTypeMap: Map<string, ObjectTypeDefinitionNode>;
|
|
11
|
+
inputObjectTypeMap: Map<string, InputObjectTypeDefinitionNode>;
|
|
12
|
+
unionTypeMap: Map<string, UnionTypeDefinitionNode>;
|
|
13
|
+
interfaceTypeMap: Map<string, InterfaceTypeDefinitionNode>;
|
|
14
|
+
};
|
|
15
|
+
declare function createDefinitionsMapFromSources(sources: Source$1[]): {
|
|
16
|
+
scalarTypeMap: Map<string, ScalarTypeDefinitionNode>;
|
|
17
|
+
enumTypeMap: Map<string, EnumTypeDefinitionNode>;
|
|
18
|
+
objectTypeMap: Map<string, ObjectTypeDefinitionNode>;
|
|
19
|
+
inputObjectTypeMap: Map<string, InputObjectTypeDefinitionNode>;
|
|
20
|
+
unionTypeMap: Map<string, UnionTypeDefinitionNode>;
|
|
21
|
+
interfaceTypeMap: Map<string, InterfaceTypeDefinitionNode>;
|
|
22
|
+
};
|
|
23
|
+
declare function createDefinitionsMapFromDocument(document: DocumentNode): {
|
|
24
|
+
scalarTypeMap: Map<string, ScalarTypeDefinitionNode>;
|
|
25
|
+
enumTypeMap: Map<string, EnumTypeDefinitionNode>;
|
|
26
|
+
objectTypeMap: Map<string, ObjectTypeDefinitionNode>;
|
|
27
|
+
inputObjectTypeMap: Map<string, InputObjectTypeDefinitionNode>;
|
|
28
|
+
unionTypeMap: Map<string, UnionTypeDefinitionNode>;
|
|
29
|
+
interfaceTypeMap: Map<string, InterfaceTypeDefinitionNode>;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region lib/load.d.ts
|
|
33
|
+
declare function loadSchema(schemas: string | string[], cwd: string, extraLoaders?: Loader<BaseLoaderOptions>[]): Promise<{
|
|
34
|
+
outputSchemaAst: _$graphql.GraphQLSchema;
|
|
35
|
+
outputSchema: _$graphql.DocumentNode;
|
|
36
|
+
}>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region lib/module-registry.d.ts
|
|
39
|
+
type RegistryKeys = 'objects' | 'interfaces' | 'unions' | 'scalars';
|
|
40
|
+
type Registry = Record<RegistryKeys, string[]>;
|
|
41
|
+
type Picks = Record<RegistryKeys, Record<string, string[]>>;
|
|
42
|
+
type ModuleRegistry = {
|
|
43
|
+
defined: Registry;
|
|
44
|
+
picks: Picks;
|
|
45
|
+
};
|
|
46
|
+
declare function createModuleRegistry(document: DocumentNode): ModuleRegistry;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region lib/scalar.d.ts
|
|
49
|
+
declare function isScalarType(definitionsMap: DefinitionsMap, defaultScalars: string[], type: NamedTypeNode): boolean;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region lib/source.d.ts
|
|
52
|
+
declare function groupSourcesByModule(sources: Source[], basePath: string): Map<string, Source[]>;
|
|
53
|
+
declare function getSourcesFromSchema(schema: GraphQLSchema): Source[];
|
|
54
|
+
//#endregion
|
|
55
|
+
export { DefinitionsMap, ModuleRegistry, Picks, Registry, RegistryKeys, type Source, createDefinitionsMapFromDocument, createDefinitionsMapFromSources, createModuleRegistry, getSourcesFromSchema, groupSourcesByModule, isScalarType, loadSchema };
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { validateSchema, visit } from "graphql";
|
|
2
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
3
|
+
import { loadSchema as loadSchema$1 } from "@graphql-tools/load";
|
|
4
|
+
import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
|
|
5
|
+
import { normalize } from "@baeta/util-path";
|
|
6
|
+
//#region lib/definitions-map.ts
|
|
7
|
+
function createRegistry() {
|
|
8
|
+
return {
|
|
9
|
+
scalarTypeMap: /* @__PURE__ */ new Map(),
|
|
10
|
+
enumTypeMap: /* @__PURE__ */ new Map(),
|
|
11
|
+
objectTypeMap: /* @__PURE__ */ new Map(),
|
|
12
|
+
inputObjectTypeMap: /* @__PURE__ */ new Map(),
|
|
13
|
+
unionTypeMap: /* @__PURE__ */ new Map(),
|
|
14
|
+
interfaceTypeMap: /* @__PURE__ */ new Map()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createDefinitionsMapFromSources(sources) {
|
|
18
|
+
const registry = createRegistry();
|
|
19
|
+
for (const source of sources) if (source.document) collectTypesFromDocument(source.document, registry, [
|
|
20
|
+
"Query",
|
|
21
|
+
"Mutation",
|
|
22
|
+
"Subscription"
|
|
23
|
+
]);
|
|
24
|
+
return registry;
|
|
25
|
+
}
|
|
26
|
+
function createDefinitionsMapFromDocument(document) {
|
|
27
|
+
const registry = createRegistry();
|
|
28
|
+
collectTypesFromDocument(document, registry);
|
|
29
|
+
return registry;
|
|
30
|
+
}
|
|
31
|
+
function collectTypesFromDocument(document, registry, filterObjectTypes = []) {
|
|
32
|
+
visit(document, {
|
|
33
|
+
ScalarTypeDefinition(node) {
|
|
34
|
+
if (registry.scalarTypeMap.has(node.name.value)) throw new Error(`Scalar type ${node.name.value} already exists`);
|
|
35
|
+
registry.scalarTypeMap.set(node.name.value, node);
|
|
36
|
+
},
|
|
37
|
+
EnumTypeDefinition(node) {
|
|
38
|
+
if (registry.enumTypeMap.has(node.name.value)) throw new Error(`Enum type ${node.name.value} already exists, use 'extend' instead!`);
|
|
39
|
+
registry.enumTypeMap.set(node.name.value, node);
|
|
40
|
+
},
|
|
41
|
+
ObjectTypeDefinition(node) {
|
|
42
|
+
if (filterObjectTypes.includes(node.name.value)) return;
|
|
43
|
+
if (registry.objectTypeMap.has(node.name.value)) throw new Error(`Object type ${node.name.value} already exists, use 'extend' instead!`);
|
|
44
|
+
registry.objectTypeMap.set(node.name.value, node);
|
|
45
|
+
},
|
|
46
|
+
InputObjectTypeDefinition(node) {
|
|
47
|
+
if (registry.inputObjectTypeMap.has(node.name.value)) throw new Error(`Input type ${node.name.value} already exists. Use 'extend' instead!`);
|
|
48
|
+
registry.inputObjectTypeMap.set(node.name.value, node);
|
|
49
|
+
},
|
|
50
|
+
UnionTypeDefinition(node) {
|
|
51
|
+
if (registry.unionTypeMap.has(node.name.value)) throw new Error(`Union type ${node.name.value} already exists, use 'extend' instead!`);
|
|
52
|
+
registry.unionTypeMap.set(node.name.value, node);
|
|
53
|
+
},
|
|
54
|
+
InterfaceTypeDefinition(node) {
|
|
55
|
+
if (registry.interfaceTypeMap.has(node.name.value)) throw new Error(`Interface type ${node.name.value} already exists. Use 'extend' instead!`);
|
|
56
|
+
registry.interfaceTypeMap.set(node.name.value, node);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region lib/load.ts
|
|
62
|
+
async function loadSchema(schemas, cwd, extraLoaders = []) {
|
|
63
|
+
const schemaPointerMap = {};
|
|
64
|
+
for (const ptr of Array.isArray(schemas) ? schemas : [schemas]) schemaPointerMap[ptr] = {};
|
|
65
|
+
const outputSchemaAst = await loadSchema$1(schemaPointerMap, {
|
|
66
|
+
loaders: [new GraphQLFileLoader(), ...extraLoaders],
|
|
67
|
+
cwd,
|
|
68
|
+
includeSources: true
|
|
69
|
+
});
|
|
70
|
+
const errors = validateSchema(outputSchemaAst);
|
|
71
|
+
if (errors.length > 0) {
|
|
72
|
+
const messages = errors.map((e) => e.toString()).join("\n\n--------------------\n\n");
|
|
73
|
+
const subject = errors.length === 1 ? "error" : "errors";
|
|
74
|
+
throw new Error(`Invalid schema. Found ${errors.length} ${subject}:\n\n${messages}`);
|
|
75
|
+
}
|
|
76
|
+
if (!outputSchemaAst.extensions) outputSchemaAst.extensions = {};
|
|
77
|
+
return {
|
|
78
|
+
outputSchemaAst,
|
|
79
|
+
outputSchema: getDocumentNodeFromSchema(outputSchemaAst)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region lib/module-registry.ts
|
|
84
|
+
const registryKeys = [
|
|
85
|
+
"objects",
|
|
86
|
+
"interfaces",
|
|
87
|
+
"unions",
|
|
88
|
+
"scalars"
|
|
89
|
+
];
|
|
90
|
+
function createModuleRegistry(document) {
|
|
91
|
+
const picks = createObject(registryKeys, () => ({}));
|
|
92
|
+
const defined = createObject(registryKeys, () => []);
|
|
93
|
+
visit(document, {
|
|
94
|
+
ObjectTypeDefinition(node) {
|
|
95
|
+
defined.objects.push(node.name.value);
|
|
96
|
+
collectFields(node, picks.objects);
|
|
97
|
+
},
|
|
98
|
+
ObjectTypeExtension(node) {
|
|
99
|
+
pushUnique(defined.objects, node.name.value);
|
|
100
|
+
collectFields(node, picks.objects);
|
|
101
|
+
},
|
|
102
|
+
InterfaceTypeDefinition(node) {
|
|
103
|
+
defined.interfaces.push(node.name.value);
|
|
104
|
+
collectFields(node, picks.interfaces);
|
|
105
|
+
},
|
|
106
|
+
UnionTypeDefinition(node) {
|
|
107
|
+
defined.unions.push(node.name.value);
|
|
108
|
+
collectUnionTypes(node, picks);
|
|
109
|
+
},
|
|
110
|
+
ScalarTypeDefinition(node) {
|
|
111
|
+
defined.scalars.push(node.name.value);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
defined,
|
|
116
|
+
picks
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function collectFields(node, picksObj) {
|
|
120
|
+
const name = node.name.value;
|
|
121
|
+
if (node.fields) {
|
|
122
|
+
if (!picksObj[name]) picksObj[name] = [];
|
|
123
|
+
for (const field of node.fields) picksObj[name].push(field.name.value);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function collectUnionTypes(node, picks) {
|
|
127
|
+
const name = node.name.value;
|
|
128
|
+
if (node.types) {
|
|
129
|
+
if (!picks.unions[name]) picks.unions[name] = [];
|
|
130
|
+
for (const type of node.types) picks.unions[name].push(type.name.value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function pushUnique(list, item) {
|
|
134
|
+
if (!list.includes(item)) list.push(item);
|
|
135
|
+
}
|
|
136
|
+
function createObject(keys, valueFn) {
|
|
137
|
+
const obj = {};
|
|
138
|
+
for (const key of keys) obj[key] = valueFn(key);
|
|
139
|
+
return obj;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region lib/scalar.ts
|
|
143
|
+
function isScalarType(definitionsMap, defaultScalars, type) {
|
|
144
|
+
return definitionsMap.scalarTypeMap.has(type.name.value) || defaultScalars.includes(type.name.value);
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region lib/source.ts
|
|
148
|
+
const SEP = "/";
|
|
149
|
+
function groupSourcesByModule(sources, basePath) {
|
|
150
|
+
const map = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const source of sources) {
|
|
152
|
+
if (!source.location) continue;
|
|
153
|
+
const relativePath = getRelativePath(source.location, basePath);
|
|
154
|
+
if (!relativePath) continue;
|
|
155
|
+
const mod = extractModuleDirectory(relativePath);
|
|
156
|
+
const existing = map.get(mod) ?? [];
|
|
157
|
+
existing.push(source);
|
|
158
|
+
map.set(mod, existing);
|
|
159
|
+
}
|
|
160
|
+
return map;
|
|
161
|
+
}
|
|
162
|
+
function getSourcesFromSchema(schema) {
|
|
163
|
+
return schema.extensions?.extendedSources ?? [];
|
|
164
|
+
}
|
|
165
|
+
function extractModuleDirectory(relativePath) {
|
|
166
|
+
const [moduleDirectory] = relativePath.split(SEP);
|
|
167
|
+
return moduleDirectory;
|
|
168
|
+
}
|
|
169
|
+
function getRelativePath(filepath, basePath) {
|
|
170
|
+
const normalizedFilepath = ensureStartsWithSeparator(ensureEndsWithSeparator(normalize(filepath)));
|
|
171
|
+
const normalizedBasePath = ensureStartsWithSeparator(ensureEndsWithSeparator(normalize(basePath)));
|
|
172
|
+
const [, relativePath] = normalizedFilepath.split(normalizedBasePath);
|
|
173
|
+
return relativePath;
|
|
174
|
+
}
|
|
175
|
+
function ensureStartsWithSeparator(path) {
|
|
176
|
+
return path.startsWith(SEP) ? path : SEP + path;
|
|
177
|
+
}
|
|
178
|
+
function ensureEndsWithSeparator(path) {
|
|
179
|
+
return path.endsWith(SEP) ? path : path + SEP;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { createDefinitionsMapFromDocument, createDefinitionsMapFromSources, createModuleRegistry, getSourcesFromSchema, groupSourcesByModule, isScalarType, loadSchema };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["loadSchemaToolkit"],"sources":["../lib/definitions-map.ts","../lib/load.ts","../lib/module-registry.ts","../lib/scalar.ts","../lib/source.ts"],"sourcesContent":["import type { Source } from '@graphql-tools/utils';\nimport {\n\ttype DocumentNode,\n\ttype EnumTypeDefinitionNode,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InterfaceTypeDefinitionNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype ScalarTypeDefinitionNode,\n\ttype UnionTypeDefinitionNode,\n\tvisit,\n} from 'graphql';\n\nexport type DefinitionsMap = ReturnType<typeof createRegistry>;\n\nfunction createRegistry() {\n\treturn {\n\t\tscalarTypeMap: new Map<string, ScalarTypeDefinitionNode>(),\n\t\tenumTypeMap: new Map<string, EnumTypeDefinitionNode>(),\n\t\tobjectTypeMap: new Map<string, ObjectTypeDefinitionNode>(),\n\t\tinputObjectTypeMap: new Map<string, InputObjectTypeDefinitionNode>(),\n\t\tunionTypeMap: new Map<string, UnionTypeDefinitionNode>(),\n\t\tinterfaceTypeMap: new Map<string, InterfaceTypeDefinitionNode>(),\n\t};\n}\n\nexport function createDefinitionsMapFromSources(sources: Source[]) {\n\tconst registry = createRegistry();\n\tfor (const source of sources) {\n\t\tif (source.document) {\n\t\t\tcollectTypesFromDocument(source.document, registry, ['Query', 'Mutation', 'Subscription']);\n\t\t}\n\t}\n\treturn registry;\n}\n\nexport function createDefinitionsMapFromDocument(document: DocumentNode) {\n\tconst registry = createRegistry();\n\tcollectTypesFromDocument(document, registry);\n\treturn registry;\n}\n\nfunction collectTypesFromDocument(\n\tdocument: DocumentNode,\n\tregistry: DefinitionsMap,\n\tfilterObjectTypes: string[] = [],\n) {\n\tvisit(document, {\n\t\tScalarTypeDefinition(node) {\n\t\t\tif (registry.scalarTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Scalar type ${node.name.value} already exists`);\n\t\t\t}\n\t\t\tregistry.scalarTypeMap.set(node.name.value, node);\n\t\t},\n\t\tEnumTypeDefinition(node) {\n\t\t\tif (registry.enumTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Enum type ${node.name.value} already exists, use 'extend' instead!`);\n\t\t\t}\n\t\t\tregistry.enumTypeMap.set(node.name.value, node);\n\t\t},\n\t\tObjectTypeDefinition(node) {\n\t\t\tif (filterObjectTypes.includes(node.name.value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (registry.objectTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Object type ${node.name.value} already exists, use 'extend' instead!`);\n\t\t\t}\n\t\t\tregistry.objectTypeMap.set(node.name.value, node);\n\t\t},\n\t\tInputObjectTypeDefinition(node) {\n\t\t\tif (registry.inputObjectTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Input type ${node.name.value} already exists. Use 'extend' instead!`);\n\t\t\t}\n\t\t\tregistry.inputObjectTypeMap.set(node.name.value, node);\n\t\t},\n\t\tUnionTypeDefinition(node) {\n\t\t\tif (registry.unionTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Union type ${node.name.value} already exists, use 'extend' instead!`);\n\t\t\t}\n\t\t\tregistry.unionTypeMap.set(node.name.value, node);\n\t\t},\n\t\tInterfaceTypeDefinition(node) {\n\t\t\tif (registry.interfaceTypeMap.has(node.name.value)) {\n\t\t\t\tthrow new Error(`Interface type ${node.name.value} already exists. Use 'extend' instead!`);\n\t\t\t}\n\t\t\tregistry.interfaceTypeMap.set(node.name.value, node);\n\t\t},\n\t});\n}\n","import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';\nimport {\n\tloadSchema as loadSchemaToolkit,\n\ttype UnnormalizedTypeDefPointer,\n} from '@graphql-tools/load';\nimport {\n\ttype BaseLoaderOptions,\n\tgetDocumentNodeFromSchema,\n\ttype Loader,\n} from '@graphql-tools/utils';\nimport { validateSchema } from 'graphql';\n\nexport async function loadSchema(\n\tschemas: string | string[],\n\tcwd: string,\n\textraLoaders: Loader<BaseLoaderOptions>[] = [],\n) {\n\tconst schemaPointerMap: UnnormalizedTypeDefPointer = {};\n\tfor (const ptr of Array.isArray(schemas) ? schemas : [schemas]) {\n\t\tschemaPointerMap[ptr] = {};\n\t}\n\n\tconst outputSchemaAst = await loadSchemaToolkit(schemaPointerMap, {\n\t\tloaders: [new GraphQLFileLoader(), ...extraLoaders],\n\t\tcwd,\n\t\tincludeSources: true,\n\t});\n\n\tconst errors = validateSchema(outputSchemaAst);\n\n\tif (errors.length > 0) {\n\t\tconst messages = errors.map((e) => e.toString()).join('\\n\\n--------------------\\n\\n');\n\t\tconst subject = errors.length === 1 ? 'error' : 'errors';\n\t\tthrow new Error(`Invalid schema. Found ${errors.length} ${subject}:\\n\\n${messages}`);\n\t}\n\n\tif (!outputSchemaAst.extensions) {\n\t\toutputSchemaAst.extensions = {};\n\t}\n\n\treturn {\n\t\toutputSchemaAst,\n\t\toutputSchema: getDocumentNodeFromSchema(outputSchemaAst),\n\t};\n}\n","import {\n\ttype DocumentNode,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InputObjectTypeExtensionNode,\n\ttype InterfaceTypeDefinitionNode,\n\ttype InterfaceTypeExtensionNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype ObjectTypeExtensionNode,\n\ttype UnionTypeDefinitionNode,\n\tvisit,\n} from 'graphql';\n\nexport type RegistryKeys = 'objects' | 'interfaces' | 'unions' | 'scalars';\nexport type Registry = Record<RegistryKeys, string[]>;\nexport type Picks = Record<RegistryKeys, Record<string, string[]>>;\n\nconst registryKeys: RegistryKeys[] = ['objects', 'interfaces', 'unions', 'scalars'];\n\nexport type ModuleRegistry = {\n\tdefined: Registry;\n\tpicks: Picks;\n};\n\nexport function createModuleRegistry(document: DocumentNode): ModuleRegistry {\n\tconst picks: Record<RegistryKeys, Record<string, string[]>> = createObject(\n\t\tregistryKeys,\n\t\t() => ({}),\n\t);\n\tconst defined: Registry = createObject(registryKeys, () => []);\n\n\tvisit(document, {\n\t\tObjectTypeDefinition(node) {\n\t\t\tdefined.objects.push(node.name.value);\n\t\t\tcollectFields(node, picks.objects);\n\t\t},\n\t\tObjectTypeExtension(node) {\n\t\t\tpushUnique(defined.objects, node.name.value);\n\t\t\tcollectFields(node, picks.objects);\n\t\t},\n\t\tInterfaceTypeDefinition(node) {\n\t\t\tdefined.interfaces.push(node.name.value);\n\t\t\tcollectFields(node, picks.interfaces);\n\t\t},\n\t\tUnionTypeDefinition(node) {\n\t\t\tdefined.unions.push(node.name.value);\n\t\t\tcollectUnionTypes(node, picks);\n\t\t},\n\t\tScalarTypeDefinition(node) {\n\t\t\tdefined.scalars.push(node.name.value);\n\t\t},\n\t});\n\n\treturn {\n\t\tdefined,\n\t\tpicks,\n\t};\n}\n\nfunction collectFields(\n\tnode:\n\t\t| ObjectTypeDefinitionNode\n\t\t| ObjectTypeExtensionNode\n\t\t| InterfaceTypeDefinitionNode\n\t\t| InterfaceTypeExtensionNode\n\t\t| InputObjectTypeDefinitionNode\n\t\t| InputObjectTypeExtensionNode,\n\tpicksObj: Record<string, string[]>,\n) {\n\tconst name = node.name.value;\n\tif (node.fields) {\n\t\tif (!picksObj[name]) {\n\t\t\tpicksObj[name] = [];\n\t\t}\n\t\tfor (const field of node.fields) {\n\t\t\tpicksObj[name].push(field.name.value);\n\t\t}\n\t}\n}\n\nfunction collectUnionTypes(node: UnionTypeDefinitionNode, picks: Picks) {\n\tconst name = node.name.value;\n\tif (node.types) {\n\t\tif (!picks.unions[name]) {\n\t\t\tpicks.unions[name] = [];\n\t\t}\n\t\tfor (const type of node.types) {\n\t\t\tpicks.unions[name].push(type.name.value);\n\t\t}\n\t}\n}\n\nfunction pushUnique<T>(list: T[], item: T): void {\n\tif (!list.includes(item)) {\n\t\tlist.push(item);\n\t}\n}\n\nfunction createObject<K extends string, T>(keys: K[], valueFn: (key: K) => T) {\n\tconst obj: Record<K, T> = {} as Record<K, T>;\n\tfor (const key of keys) {\n\t\tobj[key] = valueFn(key);\n\t}\n\treturn obj;\n}\n","import type { NamedTypeNode } from 'graphql';\nimport type { DefinitionsMap } from './definitions-map.ts';\n\nexport function isScalarType(\n\tdefinitionsMap: DefinitionsMap,\n\tdefaultScalars: string[],\n\ttype: NamedTypeNode,\n): boolean {\n\treturn (\n\t\tdefinitionsMap.scalarTypeMap.has(type.name.value) || defaultScalars.includes(type.name.value)\n\t);\n}\n","import { normalize } from '@baeta/util-path';\nimport type { Source } from '@graphql-tools/utils';\nimport type { GraphQLSchema } from 'graphql';\n\nexport type { Source };\n\nconst SEP = '/';\n\nexport function groupSourcesByModule(sources: Source[], basePath: string) {\n\tconst map = new Map<string, Source[]>();\n\tfor (const source of sources) {\n\t\tif (!source.location) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst relativePath = getRelativePath(source.location, basePath);\n\t\tif (!relativePath) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst mod = extractModuleDirectory(relativePath);\n\t\tconst existing = map.get(mod) ?? [];\n\t\texisting.push(source);\n\t\tmap.set(mod, existing);\n\t}\n\treturn map;\n}\n\nexport function getSourcesFromSchema(schema: GraphQLSchema) {\n\tconst extensions = schema.extensions;\n\treturn (extensions?.extendedSources ?? []) as Source[];\n}\n\nfunction extractModuleDirectory(relativePath: string): string {\n\tconst [moduleDirectory] = relativePath.split(SEP);\n\treturn moduleDirectory;\n}\n\nfunction getRelativePath(filepath: string, basePath: string) {\n\tconst normalizedFilepath = ensureStartsWithSeparator(\n\t\tensureEndsWithSeparator(normalize(filepath)),\n\t);\n\tconst normalizedBasePath = ensureStartsWithSeparator(\n\t\tensureEndsWithSeparator(normalize(basePath)),\n\t);\n\tconst [, relativePath] = normalizedFilepath.split(normalizedBasePath);\n\treturn relativePath;\n}\n\nfunction ensureStartsWithSeparator(path: string) {\n\treturn path.startsWith(SEP) ? path : SEP + path;\n}\n\nfunction ensureEndsWithSeparator(path: string) {\n\treturn path.endsWith(SEP) ? path : path + SEP;\n}\n"],"mappings":";;;;;;AAcA,SAAS,iBAAiB;AACzB,QAAO;EACN,+BAAe,IAAI,KAAuC;EAC1D,6BAAa,IAAI,KAAqC;EACtD,+BAAe,IAAI,KAAuC;EAC1D,oCAAoB,IAAI,KAA4C;EACpE,8BAAc,IAAI,KAAsC;EACxD,kCAAkB,IAAI,KAA0C;EAChE;;AAGF,SAAgB,gCAAgC,SAAmB;CAClE,MAAM,WAAW,gBAAgB;AACjC,MAAK,MAAM,UAAU,QACpB,KAAI,OAAO,SACV,0BAAyB,OAAO,UAAU,UAAU;EAAC;EAAS;EAAY;EAAe,CAAC;AAG5F,QAAO;;AAGR,SAAgB,iCAAiC,UAAwB;CACxE,MAAM,WAAW,gBAAgB;AACjC,0BAAyB,UAAU,SAAS;AAC5C,QAAO;;AAGR,SAAS,yBACR,UACA,UACA,oBAA8B,EAAE,EAC/B;AACD,OAAM,UAAU;EACf,qBAAqB,MAAM;AAC1B,O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uBAAuB,cAA8B;CAC7D,MAAM,CAAC,mBAAmB,aAAa,MAAM,IAAI;AACjD,QAAO;;AAGR,SAAS,gBAAgB,UAAkB,UAAkB;CAC5D,MAAM,qBAAqB,0BAC1B,wBAAwB,UAAU,SAAS,CAAC,CAC5C;CACD,MAAM,qBAAqB,0BAC1B,wBAAwB,UAAU,SAAS,CAAC,CAC5C;CACD,MAAM,GAAG,gBAAgB,mBAAmB,MAAM,mBAAmB;AACrE,QAAO;;AAGR,SAAS,0BAA0B,MAAc;AAChD,QAAO,KAAK,WAAW,IAAI,GAAG,OAAO,MAAM;;AAG5C,SAAS,wBAAwB,MAAc;AAC9C,QAAO,KAAK,SAAS,IAAI,GAAG,OAAO,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/util-graphql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -25,10 +25,70 @@
|
|
|
25
25
|
"url": "https://github.com/andreisergiu98"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
28
35
|
"files": [
|
|
36
|
+
"dist",
|
|
29
37
|
"package.json"
|
|
30
38
|
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "builder build",
|
|
41
|
+
"check:deps": "builder check-deps",
|
|
42
|
+
"prepack": "builder prepare",
|
|
43
|
+
"postpack": "builder prepare --restore",
|
|
44
|
+
"test": "builder test",
|
|
45
|
+
"types": "tsc --noEmit"
|
|
46
|
+
},
|
|
47
|
+
"ava": {
|
|
48
|
+
"extensions": [
|
|
49
|
+
"ts"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@baeta/util-path": "^2.0.0-next.4",
|
|
54
|
+
"@graphql-tools/graphql-file-loader": "^8.1.14",
|
|
55
|
+
"@graphql-tools/load": "^8.1.10",
|
|
56
|
+
"@graphql-tools/utils": "^11.1.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@baeta/builder": "^0.0.0",
|
|
60
|
+
"@baeta/testing": "^0.0.0",
|
|
61
|
+
"@baeta/tsconfig": "^0.0.0",
|
|
62
|
+
"@types/node": "^22.19.17",
|
|
63
|
+
"graphql": "^16.6.0",
|
|
64
|
+
"typescript": "^6.0.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"graphql": "^16.6.0"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=22.20.0"
|
|
71
|
+
},
|
|
31
72
|
"publishConfig": {
|
|
32
|
-
"access": "public"
|
|
73
|
+
"access": "public",
|
|
74
|
+
"exports": {
|
|
75
|
+
".": {
|
|
76
|
+
"types": "./dist/index.d.ts",
|
|
77
|
+
"default": "./dist/index.js"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"typedocOptions": {
|
|
82
|
+
"entryPoints": [
|
|
83
|
+
"./index.ts"
|
|
84
|
+
],
|
|
85
|
+
"readme": "none",
|
|
86
|
+
"tsconfig": "./tsconfig.json",
|
|
87
|
+
"sort": [
|
|
88
|
+
"kind",
|
|
89
|
+
"instance-first",
|
|
90
|
+
"required-first",
|
|
91
|
+
"alphabetical-ignoring-documents"
|
|
92
|
+
]
|
|
33
93
|
}
|
|
34
|
-
}
|
|
94
|
+
}
|