@ramathibodi/nuxt-commons 4.0.9 → 4.0.10
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/module.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface graphqlVariable {
|
|
2
2
|
name: string
|
|
3
|
-
|
|
3
|
+
// `true` for `[T]`, `[true]` for `[T!]` — matches gql-query-builder's
|
|
4
|
+
// VariableOptions shape so element non-null survives into the query string.
|
|
5
|
+
list?: boolean | [boolean]
|
|
4
6
|
required?: boolean
|
|
5
7
|
type?: string
|
|
6
8
|
value?: any
|
package/package.json
CHANGED
|
@@ -6,14 +6,21 @@ function capitalizeFirstLetter(string) {
|
|
|
6
6
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// `inList` flips to true the moment we descend into a ListType, so a NonNullType
|
|
10
|
+
// nested under a List is recognized as element-non-null (`[T!]`) rather than
|
|
11
|
+
// overwriting the outer list's `required` flag. The element-non-null is encoded
|
|
12
|
+
// as `list: [true]` — the shape gql-query-builder reads to emit `[T!]`.
|
|
13
|
+
function inputTypeToObject(inputType, result, inList = false) {
|
|
10
14
|
if (inputType.kind === 'NonNullType') {
|
|
11
|
-
result['
|
|
12
|
-
|
|
15
|
+
if (inList) result['list'] = [true]
|
|
16
|
+
else result['required'] = true
|
|
17
|
+
inputTypeToObject(inputType.type, result, inList)
|
|
18
|
+
return
|
|
13
19
|
}
|
|
14
20
|
if (inputType.kind === 'ListType') {
|
|
15
|
-
result['list'] = true
|
|
16
|
-
inputTypeToObject(inputType.type, result)
|
|
21
|
+
if (!Array.isArray(result['list'])) result['list'] = true
|
|
22
|
+
inputTypeToObject(inputType.type, result, true)
|
|
23
|
+
return
|
|
17
24
|
}
|
|
18
25
|
if (inputType.kind === 'NamedType') {
|
|
19
26
|
result['type'] = inputType.name.value
|
|
@@ -21,6 +28,7 @@ function inputTypeToObject(inputType, result) {
|
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
module.exports = {
|
|
31
|
+
inputTypeToObject,
|
|
24
32
|
plugin(schema, _documents, _config) {
|
|
25
33
|
const astNode = getCachedDocumentNodeFromSchema(schema) // Transforms the GraphQLSchema into ASTNode
|
|
26
34
|
|