From f2d1738f7b1af95d069217ecf67021503b99e70f Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 19 Jul 2023 13:09:01 -0700 Subject: [PATCH] feat: working unraid-api gql --- codegen.ts | 54 + .../DropdownConnectStatus.fragment.ts | 15 + .../UserProfile/DropdownConnectStatus.vue | 19 +- composables/gql/fragment-masking.ts | 66 + composables/gql/gql.ts | 47 + composables/gql/graphql.ts | 1600 ++++++ composables/gql/index.ts | 2 + composables/services/apollo.ts | 8 +- fix-array-type.ts | 17 + package-lock.json | 4994 +++++++++++++++-- package.json | 7 +- store/server.ts | 2 +- store/unraidApi.ts | 18 +- 13 files changed, 6321 insertions(+), 528 deletions(-) create mode 100644 codegen.ts create mode 100644 components/UserProfile/DropdownConnectStatus.fragment.ts create mode 100644 composables/gql/fragment-masking.ts create mode 100644 composables/gql/gql.ts create mode 100644 composables/gql/graphql.ts create mode 100644 composables/gql/index.ts create mode 100644 fix-array-type.ts diff --git a/codegen.ts b/codegen.ts new file mode 100644 index 000000000..e7b5551e4 --- /dev/null +++ b/codegen.ts @@ -0,0 +1,54 @@ +import type { CodegenConfig } from '@graphql-codegen/cli'; + +const getApiCodegenUrl = () => { + if (process.env.USE_LOCAL_CODEGEN === 'true') { + return 'http://localhost:3001/graphql'; + } + return ''; +}; + +const config: CodegenConfig = { + overwrite: true, + documents: ['./**/**/*.ts'], + ignoreNoDocuments: false, + config: { + namingConvention: { + typeNames: './fix-array-type.ts', + }, + scalars: { + DateTime: 'string', + Long: 'number', + JSON: 'string', + URL: 'URL', + Port: 'number', + UUID: 'string', + }, + }, + generates: { + 'composables/gql/': { + preset: 'client', + config: { + useTypeImports: true, + }, + schema: [ + { + 'http://localhost:3001/graphql': { + headers: { + origin: `/var/run/unraid-php.sock`, + 'x-api-key': 'unupc_fab6ff6ffe51040595c6d9ffb63a353ba16cc2ad7d93f813a2e80a5810', + }, + }, + }, + ], + plugins: [ + { + add: { + content: '/* eslint-disable */', + }, + }, + ], + }, + }, +}; + +export default config; diff --git a/components/UserProfile/DropdownConnectStatus.fragment.ts b/components/UserProfile/DropdownConnectStatus.fragment.ts new file mode 100644 index 000000000..b58e38435 --- /dev/null +++ b/components/UserProfile/DropdownConnectStatus.fragment.ts @@ -0,0 +1,15 @@ +import { graphql } from "~/composables/gql/gql"; + +export const TEST_FRAGMENT = graphql(/* GraphQL */` + fragment TestFragment on Cloud { + error + } +`); + +export const TEST_QUERY = graphql(/* GraphQL */` + query cloudError { + cloud { + ...TestFragment + } + } +`); diff --git a/components/UserProfile/DropdownConnectStatus.vue b/components/UserProfile/DropdownConnectStatus.vue index bc8a90285..0520433eb 100644 --- a/components/UserProfile/DropdownConnectStatus.vue +++ b/components/UserProfile/DropdownConnectStatus.vue @@ -1,8 +1,21 @@