@soda-gql/core 0.11.0 → 0.11.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/dist/index-Bj60NxMb.d.cts.map +1 -1
- package/dist/{index-BcA2XPEk.d.ts → index-DPtgl2f4.d.ts} +58 -6
- package/dist/index-DPtgl2f4.d.ts.map +1 -0
- package/dist/{index-CatAewXz.d.cts → index-IMOOkvQf.d.cts} +58 -6
- package/dist/index-IMOOkvQf.d.cts.map +1 -0
- package/dist/index.cjs +32 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.cts.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-BcA2XPEk.d.ts.map +0 -1
- package/dist/index-CatAewXz.d.cts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -169,22 +169,21 @@ const validateDirectiveLocation = (directive, expectedLocation) => {
|
|
|
169
169
|
* @param schema - The schema for type lookups
|
|
170
170
|
* @returns Array of DirectiveNode for the GraphQL AST
|
|
171
171
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* in directives will be output as strings. This can be enhanced when
|
|
175
|
-
* directive definitions are added to the schema.
|
|
172
|
+
* Uses argument specifiers from DirectiveRef (when available via createTypedDirectiveMethod)
|
|
173
|
+
* to properly output enum arguments as Kind.ENUM instead of Kind.STRING.
|
|
176
174
|
*/
|
|
177
175
|
const buildDirectives = (directives, location, schema) => {
|
|
178
176
|
return directives.filter((d) => d instanceof DirectiveRef).map((directive) => {
|
|
179
177
|
validateDirectiveLocation(directive, location);
|
|
180
178
|
const inner = DirectiveRef.getInner(directive);
|
|
179
|
+
const argumentSpecifiers = inner.argumentSpecs ?? {};
|
|
181
180
|
return {
|
|
182
181
|
kind: graphql.Kind.DIRECTIVE,
|
|
183
182
|
name: {
|
|
184
183
|
kind: graphql.Kind.NAME,
|
|
185
184
|
value: inner.name
|
|
186
185
|
},
|
|
187
|
-
arguments: buildArguments(inner.arguments,
|
|
186
|
+
arguments: buildArguments(inner.arguments, argumentSpecifiers, schema)
|
|
188
187
|
};
|
|
189
188
|
});
|
|
190
189
|
};
|
|
@@ -486,6 +485,33 @@ const createDirectiveMethod = (name, locations) => {
|
|
|
486
485
|
});
|
|
487
486
|
};
|
|
488
487
|
/**
|
|
488
|
+
* Creates a typed directive method with argument type specifiers.
|
|
489
|
+
* Enables enum value output in directive arguments.
|
|
490
|
+
*
|
|
491
|
+
* @param name - The directive name (without @)
|
|
492
|
+
* @param locations - Valid locations where the directive can be applied
|
|
493
|
+
* @param argSpecs - Type specifiers for directive arguments
|
|
494
|
+
* @returns A function that creates DirectiveRef instances with argument type info
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* const authMethod = createTypedDirectiveMethod(
|
|
499
|
+
* "auth",
|
|
500
|
+
* ["FIELD"] as const,
|
|
501
|
+
* { role: { kind: "enum", name: "Role", modifier: "!" } }
|
|
502
|
+
* );
|
|
503
|
+
* const authDirective = authMethod({ role: "ADMIN" });
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
const createTypedDirectiveMethod = (name, locations, argSpecs) => {
|
|
507
|
+
return (args) => new DirectiveRef({
|
|
508
|
+
name,
|
|
509
|
+
arguments: args,
|
|
510
|
+
locations,
|
|
511
|
+
argumentSpecs: argSpecs
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
489
515
|
* Standard directive locations for @skip and @include.
|
|
490
516
|
*/
|
|
491
517
|
const CONDITIONAL_DIRECTIVE_LOCATIONS = [
|
|
@@ -1723,6 +1749,7 @@ exports.createGqlElementComposer = createGqlElementComposer;
|
|
|
1723
1749
|
exports.createGqlFragmentComposers = createGqlFragmentComposers;
|
|
1724
1750
|
exports.createOperationComposerFactory = createOperationComposerFactory;
|
|
1725
1751
|
exports.createStandardDirectives = createStandardDirectives;
|
|
1752
|
+
exports.createTypedDirectiveMethod = createTypedDirectiveMethod;
|
|
1726
1753
|
exports.createVarAssignments = createVarAssignments;
|
|
1727
1754
|
exports.createVarBuilder = createVarBuilder;
|
|
1728
1755
|
exports.createVarMethod = createVarMethod;
|