@xyd-js/gql 0.0.0-build

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/TODO.md +8 -0
  5. package/__fixtures__/-1.opendocs.docs-nested/input.graphql +66 -0
  6. package/__fixtures__/-1.opendocs.docs-nested/output.json +554 -0
  7. package/__fixtures__/-1.opendocs.flat/input.graphql +19 -0
  8. package/__fixtures__/-1.opendocs.flat/output.json +243 -0
  9. package/__fixtures__/-1.opendocs.scopes/input.graphql +33 -0
  10. package/__fixtures__/-1.opendocs.scopes/output.json +378 -0
  11. package/__fixtures__/-1.opendocs.sidebar/input.graphql +44 -0
  12. package/__fixtures__/-1.opendocs.sort/input.graphql +92 -0
  13. package/__fixtures__/-1.opendocs.sort/output.json +1078 -0
  14. package/__fixtures__/-1.opendocs.sort+group/input.graphql +111 -0
  15. package/__fixtures__/-1.opendocs.sort+group/output.json +1114 -0
  16. package/__fixtures__/-1.opendocs.sort+group+path/input.graphql +118 -0
  17. package/__fixtures__/-1.opendocs.sort+group+path/output.json +1114 -0
  18. package/__fixtures__/-2.complex.github/input.graphql +69424 -0
  19. package/__fixtures__/-2.complex.github/output.json +269874 -0
  20. package/__fixtures__/-2.complex.livesession/input.graphql +23 -0
  21. package/__fixtures__/-2.complex.livesession/output.json +302 -0
  22. package/__fixtures__/-2.complex.monday/input.graphql +6089 -0
  23. package/__fixtures__/-2.complex.monday/output.json +1 -0
  24. package/__fixtures__/-3.array-non-null-return/input.graphql +9 -0
  25. package/__fixtures__/-3.array-non-null-return/output.json +151 -0
  26. package/__fixtures__/1.basic/input.graphql +118 -0
  27. package/__fixtures__/1.basic/output.json +630 -0
  28. package/__fixtures__/2.circular/input.graphql +17 -0
  29. package/__fixtures__/2.circular/output.json +248 -0
  30. package/__fixtures__/3.opendocs/input.graphql +27 -0
  31. package/__fixtures__/3.opendocs/output.json +338 -0
  32. package/__fixtures__/4.union/input.graphql +19 -0
  33. package/__fixtures__/4.union/output.json +344 -0
  34. package/__fixtures__/5.flat/input.graphql +27 -0
  35. package/__fixtures__/5.flat/output.json +383 -0
  36. package/__fixtures__/6.default-values/input.graphql +47 -0
  37. package/__fixtures__/6.default-values/output.json +655 -0
  38. package/__fixtures__/7.type-args/input.graphql +19 -0
  39. package/__fixtures__/7.type-args/output.json +301 -0
  40. package/__fixtures__/8.default-sort/input.graphql +60 -0
  41. package/__fixtures__/8.default-sort/output.json +1078 -0
  42. package/__tests__/gqlSchemaToReferences.test.ts +109 -0
  43. package/__tests__/utils.ts +45 -0
  44. package/declarations.d.ts +4 -0
  45. package/dist/index.d.ts +21 -0
  46. package/dist/index.js +1503 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/opendocs.graphql +56 -0
  49. package/index.ts +3 -0
  50. package/package.json +29 -0
  51. package/src/context.ts +17 -0
  52. package/src/converters/gql-arg.ts +51 -0
  53. package/src/converters/gql-enum.ts +27 -0
  54. package/src/converters/gql-field.ts +164 -0
  55. package/src/converters/gql-input.ts +34 -0
  56. package/src/converters/gql-interface.ts +35 -0
  57. package/src/converters/gql-mutation.ts +36 -0
  58. package/src/converters/gql-object.ts +83 -0
  59. package/src/converters/gql-operation.ts +128 -0
  60. package/src/converters/gql-query.ts +36 -0
  61. package/src/converters/gql-sample.ts +159 -0
  62. package/src/converters/gql-scalar.ts +16 -0
  63. package/src/converters/gql-subscription.ts +36 -0
  64. package/src/converters/gql-types.ts +195 -0
  65. package/src/converters/gql-union.ts +40 -0
  66. package/src/gql-core.ts +362 -0
  67. package/src/index.ts +3 -0
  68. package/src/opendocs.graphql +56 -0
  69. package/src/opendocs.ts +253 -0
  70. package/src/schema.ts +293 -0
  71. package/src/types.ts +103 -0
  72. package/src/utils.ts +25 -0
  73. package/tsconfig.json +18 -0
  74. package/tsup.config.ts +33 -0
  75. package/tsup.examples-config.ts +30 -0
  76. package/vitest.config.ts +21 -0
package/tsup.config.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { copyFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+
4
+ import {defineConfig} from 'tsup';
5
+
6
+ export default defineConfig({
7
+ entry: ['index.ts'],
8
+ format: ['esm'], // Output both ESM and CJS formats
9
+ target: 'node16', // Ensure compatibility with Node.js 16
10
+ dts: {
11
+ entry: 'index.ts', // Specify the entry for DTS
12
+ resolve: true, // Resolve external types
13
+ },
14
+ splitting: false, // Disable code splitting
15
+ sourcemap: true, // Generate source maps
16
+ clean: true, // Clean the output directory before each build
17
+ esbuildOptions: (options) => {
18
+ options.platform = 'node'; // Ensure the platform is set to Node.js
19
+ options.external = ['node:fs/promises']; // Mark 'node:fs/promises' as external
20
+ options.loader = {
21
+ '.js': 'jsx', // Ensure proper handling of .js files
22
+ '.graphql': 'text' // Load .graphql files as text
23
+ };
24
+ },
25
+ onSuccess: async () => {
26
+ // Copy opendocs.graphql to dist
27
+ copyFileSync(
28
+ join('src', 'opendocs.graphql'),
29
+ join('dist', 'opendocs.graphql')
30
+ );
31
+ return Promise.resolve();
32
+ }
33
+ });
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ // TODO: multiple entry points + outputs
4
+
5
+ const isDebugMode = !!process.env.DEBUG
6
+
7
+ export default defineConfig({
8
+ entry: [
9
+ "./examples/basic/index.ts"
10
+ ],
11
+ format: ['esm', 'cjs'], // Output both ESM and CJS formats
12
+ target: 'node16', // Ensure compatibility with Node.js 16
13
+ dts: {
14
+ entry: "./examples/basic/index.ts",
15
+ resolve: true, // Resolve external types
16
+ },
17
+ splitting: false, // Disable code splitting
18
+ sourcemap: true, // Generate source maps
19
+ clean: true, // Clean the output directory before each build
20
+ outDir: './examples/dist', // Output directory
21
+ esbuildOptions(options) {
22
+ options.minify = true;
23
+ if (isDebugMode) {
24
+ options.drop = [];
25
+ } else {
26
+ options.drop = [];
27
+ options.pure = ['console.debug'];
28
+ }
29
+ },
30
+ });
@@ -0,0 +1,21 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'node',
6
+ globals: true,
7
+ },
8
+ plugins: [
9
+ {
10
+ name: 'graphql-raw',
11
+ transform(code, id) {
12
+ if (id.endsWith('.graphql')) {
13
+ return {
14
+ code: `export default ${JSON.stringify(code)};`,
15
+ map: null
16
+ }
17
+ }
18
+ }
19
+ }
20
+ ]
21
+ })