Add graqhql introspection schema

This commit is contained in:
Daniel Egger 2023-05-16 16:36:53 +02:00
parent 41cd8d25fb
commit 8d879ba981
10 changed files with 48 additions and 20 deletions

1
.gitignore vendored
View File

@ -289,3 +289,4 @@ git-crypt-encrypted-files-check.txt
/server/vbv_lernwelt/static/vue/
/server/vbv_lernwelt/templates/vue/index.html
/server/vbv_lernwelt/media
/client/src/gql/minifiedSchema.json

View File

@ -1,9 +1,12 @@
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "../server/schema.graphql",
schema: "./src/gql/schema.graphql",
documents: ["src/**/*.vue", "src/graphql/**/*.ts"],
ignoreNoDocuments: true,
hooks: {
afterAllFileWrite: ["node minimizeGraphqlSchema.mjs"],
},
generates: {
"./src/gql/": {
preset: "client",

View File

@ -0,0 +1,11 @@
import { getIntrospectedSchema, minifyIntrospectionQuery } from "@urql/introspection";
import { readFileSync, writeFileSync } from "fs";
// Read the existing introspection schema
const schema = readFileSync("./src/gql/schema.graphql", "utf-8");
// const schema = JSON.parse(schemaJson);
const minifiedSchema = minifyIntrospectionQuery(getIntrospectedSchema(schema));
// Write the minified schema to a new file
writeFileSync("./src/gql/minifiedSchema.json", JSON.stringify(minifiedSchema));

View File

@ -14,6 +14,7 @@
"@sentry/vue": "^7.20.0",
"@urql/devtools": "^2.0.3",
"@urql/exchange-graphcache": "^6.0.4",
"@urql/introspection": "^1.0.2",
"@urql/vue": "^1.1.1",
"@vueuse/core": "^9.13.0",
"@vueuse/router": "^10.1.2",
@ -7041,6 +7042,14 @@
"wonka": "^6.3.2"
}
},
"node_modules/@urql/introspection": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@urql/introspection/-/introspection-1.0.2.tgz",
"integrity": "sha512-vPuX+DjbmL5EUsvwgAMV8dkxc7JKuuNTzDfsNvtCuVmbAED4Nx39p08HImjTWAewSatjyzZZs+fAhU7z/4P+UQ==",
"peerDependencies": {
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
}
},
"node_modules/@urql/vue": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@urql/vue/-/vue-1.1.1.tgz",
@ -24994,6 +25003,11 @@
"wonka": "^6.3.2"
}
},
"@urql/introspection": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@urql/introspection/-/introspection-1.0.2.tgz",
"integrity": "sha512-vPuX+DjbmL5EUsvwgAMV8dkxc7JKuuNTzDfsNvtCuVmbAED4Nx39p08HImjTWAewSatjyzZZs+fAhU7z/4P+UQ=="
},
"@urql/vue": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@urql/vue/-/vue-1.1.1.tgz",

View File

@ -2,10 +2,10 @@
"name": "client",
"version": "0.0.0",
"scripts": {
"build": "vue-tsc --noEmit && vite build && node versionize && cp ./dist/index.html ../server/vbv_lernwelt/templates/vue/index.html && rm -rf ../server/vbv_lernwelt/static/vue/* && cp -r ./dist/static/vue ../server/vbv_lernwelt/static/ && npm run build-storybook",
"build": "npm run codegen && vue-tsc --noEmit && vite build && node versionize && cp ./dist/index.html ../server/vbv_lernwelt/templates/vue/index.html && rm -rf ../server/vbv_lernwelt/static/vue/* && cp -r ./dist/static/vue ../server/vbv_lernwelt/static/ && npm run build-storybook",
"build-storybook": "rm -rf ../server/vbv_lernwelt/static/storybook/* && storybook build -o ../server/vbv_lernwelt/static/storybook",
"build:tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --minify",
"codegen": "graphql-codegen",
"codegen": "graphql-codegen && node minimizeGraphqlSchema.mjs",
"codegen:watch": "graphql-codegen --watch",
"coverage": "vitest run --coverage",
"cypress:open": "cypress open",
@ -16,7 +16,7 @@
"storybook": "storybook dev -p 6006",
"tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --watch",
"test": "vitest run",
"typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"typecheck": "npm run codegen && vue-tsc --noEmit -p tsconfig.app.json --composite false",
"vue-i18n-extract": "vue-i18n-extract report"
},
"dependencies": {
@ -26,6 +26,7 @@
"@sentry/vue": "^7.20.0",
"@urql/devtools": "^2.0.3",
"@urql/exchange-graphcache": "^6.0.4",
"@urql/introspection": "^1.0.2",
"@urql/vue": "^1.1.1",
"@vueuse/core": "^9.13.0",
"@vueuse/router": "^10.1.2",

View File

@ -1,3 +1,7 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import schema from "../gql/minifiedSchema.json";
import { devtoolsExchange } from "@urql/devtools";
import { cacheExchange } from "@urql/exchange-graphcache";
import { Client, fetchExchange } from "@urql/vue";
@ -7,6 +11,7 @@ export const graphqlClient = new Client({
exchanges: [
devtoolsExchange,
cacheExchange({
schema: schema,
updates: {
Mutation: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars

View File

@ -1,15 +0,0 @@
{
"name": "VBV Schema",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:8000/server/graphql/",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": false
}
}
}
}

View File

@ -568,7 +568,7 @@ OAUTH = {
GRAPHENE = {
"SCHEMA": "vbv_lernwelt.core.schema.schema",
"SCHEMA_OUTPUT": "schema.graphql",
"SCHEMA_OUTPUT": "../client/src/gql/schema.graphql",
}
# GRAPPLE = {
# "EXPOSE_GRAPHIQL": DEBUG,

View File

@ -0,0 +1,8 @@
schema: client/src/gql/schema.graphql
extensions:
endpoints:
Default GraphQL Endpoint:
url: http://localhost:8000/server/graphql/
headers:
user-agent: JS GraphQL
introspect: true