@stonecrop/graphql-client 0.2.5

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/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@stonecrop/graphql-client",
3
+ "version": "0.2.5",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/graphql-client.js",
9
+ "require": "./dist/graphql-client.umd.cjs"
10
+ }
11
+ },
12
+ "main": "dist/graphql-client.js",
13
+ "module": "dist/graphql-client.js",
14
+ "types": "src/index",
15
+ "files": [
16
+ "dist/*",
17
+ "src/**/*.ts"
18
+ ],
19
+ "dependencies": {
20
+ "graphql": "~16.6.0",
21
+ "graphql-request": "~6.0.0",
22
+ "@stonecrop/stonecrop": "0.2.5"
23
+ },
24
+ "devDependencies": {
25
+ "@miragejs/graphql": "^0.1.13",
26
+ "@types/graphql": "~14.5.0",
27
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
28
+ "@typescript-eslint/parser": "^5.59.5",
29
+ "@vitejs/plugin-vue": "^4.2.1",
30
+ "cypress": "^12.11.0",
31
+ "eslint": "^8.40.0",
32
+ "eslint-config-prettier": "^8.8.0",
33
+ "eslint-plugin-vue": "^9.11.1",
34
+ "miragejs": "^0.1.47",
35
+ "typescript": "^5.0.4",
36
+ "vite": "^4.3.5",
37
+ "vue": "^3.2.47",
38
+ "vue-router": "^4"
39
+ },
40
+ "engines": {
41
+ "node": ">=20.11.0"
42
+ },
43
+ "umd": "dist/graphql-client.umd.cjs",
44
+ "scripts": {
45
+ "build": "vite build",
46
+ "dev": "vite",
47
+ "lint": "eslint . --ext .ts,.vue",
48
+ "preview": "vite preview",
49
+ "story:build": "vite build stories/ -c stories/vite.config.ts",
50
+ "story:dev": "vite dev stories/ -c stories/vite.config.ts"
51
+ }
52
+ }
@@ -0,0 +1,6 @@
1
+ declare module '*.gql' {
2
+ import { DocumentNode } from 'graphql'
3
+ const Schema: DocumentNode
4
+
5
+ export = Schema
6
+ }
@@ -0,0 +1,51 @@
1
+ import { gql } from 'graphql-request'
2
+
3
+ const typeDefs = gql`
4
+ type Doctype {
5
+ id: ID!
6
+ name: String!
7
+ workflow: String!
8
+ schema: String!
9
+ actions: String!
10
+ }
11
+
12
+ type DoctypeField {
13
+ id: ID!
14
+ label: String!
15
+ fieldtype: String
16
+ component: String
17
+ required: Boolean
18
+ readonly: Boolean
19
+ }
20
+
21
+ type DoctypeWorkflow {
22
+ name: String!
23
+ machine: StateMachine!
24
+ }
25
+
26
+ type StateMachine {
27
+ id: ID!
28
+ }
29
+
30
+ type DoctypeAction {
31
+ eventName: String!
32
+ callback: String
33
+ }
34
+
35
+ type Query {
36
+ getMeta(doctype: String!): Doctype # ∪ error
37
+ getRecords(doctype: String!, filters: [String]): [String] # ∪ error
38
+ getRecord(doctype: String!, id: ID!): String # ∪ error
39
+ }
40
+
41
+ type Mutation {
42
+ runAction(doctype: String!, id: [ID!]!, functionName: String!): [String!]! # ∪ error
43
+ }
44
+
45
+ schema {
46
+ query: Query
47
+ mutation: Mutation
48
+ }
49
+ `
50
+
51
+ export default typeDefs
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { request } from 'graphql-request'
2
+
3
+ import { queries } from './queries'
4
+
5
+ export const methods = {
6
+ getMeta: async (doctype: string, url?: string) => {
7
+ const data: any = await request(url || '/graphql', queries.getMeta, { doctype })
8
+ return data
9
+ },
10
+ }
package/src/queries.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { gql } from 'graphql-request'
2
+
3
+ const queries = {
4
+ getMeta: gql`
5
+ query getDoctype($doctype: String!) {
6
+ getMeta(doctype: $doctype) {
7
+ id
8
+ name
9
+ workflow
10
+ schema
11
+ actions
12
+ }
13
+ }
14
+ `,
15
+ }
16
+
17
+ export { queries }