Skip to content

Commit 232d079

Browse files
committed
Add declarative definitions import service
1 parent 4d6099e commit 232d079

File tree

11 files changed

+2745
-5
lines changed

11 files changed

+2745
-5
lines changed

bin/get-graphql-schemas.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ const schemas = [
7878
localPath: './packages/app/src/cli/api/graphql/bulk-operations/admin_schema.graphql',
7979
usesLfs: true,
8080
},
81+
{
82+
owner: 'shop',
83+
repo: 'world',
84+
pathToFile: 'areas/core/shopify/db/graphql/admin_schema_unstable_public.graphql',
85+
localPath: './packages/app/src/cli/api/graphql/admin/admin_schema.graphql',
86+
usesLfs: true,
87+
},
8188
]
8289

8390

graphql.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@ export default {
8484
bulkOperations: projectFactory('bulk-operations', 'admin_schema.graphql'),
8585
webhooks: projectFactory('webhooks', 'webhooks_schema.graphql'),
8686
functions: projectFactory('functions', 'functions_cli_schema.graphql', 'app'),
87+
adminAsApp: projectFactory('admin', 'admin_schema.graphql'),
8788
},
8889
}

packages/app/project.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"{projectRoot}/src/cli/api/graphql/app-management/generated/**/*.ts",
6060
"{projectRoot}/src/cli/api/graphql/webhooks/generated/**/*.ts",
6161
"{projectRoot}/src/cli/api/graphql/functions/generated/**/*.ts",
62-
"{projectRoot}/src/cli/api/graphql/bulk-operations/generated/**/*.ts"
62+
"{projectRoot}/src/cli/api/graphql/bulk-operations/generated/**/*.ts",
63+
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
6364
],
6465
"options": {
6566
"commands": [
@@ -70,7 +71,8 @@
7071
"pnpm eslint 'src/cli/api/graphql/app-management/generated/**/*.{ts,tsx}' --fix",
7172
"pnpm eslint 'src/cli/api/graphql/webhooks/generated/**/*.{ts,tsx}' --fix",
7273
"pnpm eslint 'src/cli/api/graphql/functions/generated/**/*.{ts,tsx}' --fix",
73-
"pnpm eslint 'src/cli/api/graphql/bulk-operations/generated/**/*.{ts,tsx}' --fix"
74+
"pnpm eslint 'src/cli/api/graphql/bulk-operations/generated/**/*.{ts,tsx}' --fix",
75+
"pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix"
7476
],
7577
"cwd": "packages/app"
7678
}
@@ -163,6 +165,17 @@
163165
"cwd": "{workspaceRoot}"
164166
}
165167
},
168+
"graphql-codegen:generate:admin-as-app": {
169+
"executor": "nx:run-commands",
170+
"inputs": ["{workspaceRoot}/graphql.config.ts", "{projectRoot}/src/cli/api/graphql/admin/**/*.graphql"],
171+
"outputs": ["{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"],
172+
"options": {
173+
"commands": [
174+
"pnpm exec graphql-codegen --project=adminAsApp"
175+
],
176+
"cwd": "{workspaceRoot}"
177+
}
178+
},
166179
"graphql-codegen:postfix": {
167180
"executor": "nx:run-commands",
168181
"dependsOn": [
@@ -173,7 +186,8 @@
173186
"graphql-codegen:generate:app-management",
174187
"graphql-codegen:generate:webhooks",
175188
"graphql-codegen:generate:functions",
176-
"graphql-codegen:generate:bulk-operations"
189+
"graphql-codegen:generate:bulk-operations",
190+
"graphql-codegen:generate:admin-as-app"
177191
],
178192
"inputs": [{ "dependentTasksOutputFiles": "**/*.ts" }],
179193
"outputs": [
@@ -184,7 +198,8 @@
184198
"{projectRoot}/src/cli/api/graphql/app-management/generated/**/*.ts",
185199
"{projectRoot}/src/cli/api/graphql/webhooks/generated/**/*.ts",
186200
"{projectRoot}/src/cli/api/graphql/functions/generated/**/*.ts",
187-
"{projectRoot}/src/cli/api/graphql/bulk-operations/generated/**/*.ts"
201+
"{projectRoot}/src/cli/api/graphql/bulk-operations/generated/**/*.ts",
202+
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
188203
],
189204
"options": {
190205
"commands": [
@@ -195,7 +210,8 @@
195210
"find ./packages/app/src/cli/api/graphql/app-management/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
196211
"find ./packages/app/src/cli/api/graphql/webhooks/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
197212
"find ./packages/app/src/cli/api/graphql/functions/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
198-
"find ./packages/app/src/cli/api/graphql/bulk-operations/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;"
213+
"find ./packages/app/src/cli/api/graphql/bulk-operations/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
214+
"find ./packages/app/src/cli/api/graphql/admin/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;"
199215
],
200216
"cwd": "{workspaceRoot}"
201217
}
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
/* eslint-disable @typescript-eslint/consistent-type-definitions */
2+
import * as Types from './types.js'
3+
4+
import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'
5+
6+
export type MetafieldForImportFragment = {
7+
key: string
8+
name: string
9+
namespace: string
10+
description?: string | null
11+
type: {category: string; name: string}
12+
access: {
13+
admin?: Types.MetafieldAdminAccess | null
14+
storefront?: Types.MetafieldStorefrontAccess | null
15+
customerAccount: Types.MetafieldCustomerAccountAccess
16+
}
17+
capabilities: {adminFilterable: {enabled: boolean}}
18+
validations: {name: string; value?: string | null}[]
19+
}
20+
21+
export type MetafieldDefinitionsQueryVariables = Types.Exact<{
22+
ownerType: Types.MetafieldOwnerType
23+
after?: Types.InputMaybe<Types.Scalars['String']['input']>
24+
}>
25+
26+
export type MetafieldDefinitionsQuery = {
27+
metafieldDefinitions: {
28+
pageInfo: {hasNextPage: boolean; endCursor?: string | null}
29+
nodes: {
30+
key: string
31+
name: string
32+
namespace: string
33+
description?: string | null
34+
type: {category: string; name: string}
35+
access: {
36+
admin?: Types.MetafieldAdminAccess | null
37+
storefront?: Types.MetafieldStorefrontAccess | null
38+
customerAccount: Types.MetafieldCustomerAccountAccess
39+
}
40+
capabilities: {adminFilterable: {enabled: boolean}}
41+
validations: {name: string; value?: string | null}[]
42+
}[]
43+
}
44+
}
45+
46+
export const MetafieldForImportFragmentDoc = {
47+
kind: 'Document',
48+
definitions: [
49+
{
50+
kind: 'FragmentDefinition',
51+
name: {kind: 'Name', value: 'MetafieldForImport'},
52+
typeCondition: {kind: 'NamedType', name: {kind: 'Name', value: 'MetafieldDefinition'}},
53+
selectionSet: {
54+
kind: 'SelectionSet',
55+
selections: [
56+
{kind: 'Field', name: {kind: 'Name', value: 'key'}},
57+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
58+
{kind: 'Field', name: {kind: 'Name', value: 'namespace'}},
59+
{kind: 'Field', name: {kind: 'Name', value: 'description'}},
60+
{
61+
kind: 'Field',
62+
name: {kind: 'Name', value: 'type'},
63+
selectionSet: {
64+
kind: 'SelectionSet',
65+
selections: [
66+
{kind: 'Field', name: {kind: 'Name', value: 'category'}},
67+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
68+
],
69+
},
70+
},
71+
{
72+
kind: 'Field',
73+
name: {kind: 'Name', value: 'access'},
74+
selectionSet: {
75+
kind: 'SelectionSet',
76+
selections: [
77+
{kind: 'Field', name: {kind: 'Name', value: 'admin'}},
78+
{kind: 'Field', name: {kind: 'Name', value: 'storefront'}},
79+
{kind: 'Field', name: {kind: 'Name', value: 'customerAccount'}},
80+
],
81+
},
82+
},
83+
{
84+
kind: 'Field',
85+
name: {kind: 'Name', value: 'capabilities'},
86+
selectionSet: {
87+
kind: 'SelectionSet',
88+
selections: [
89+
{
90+
kind: 'Field',
91+
name: {kind: 'Name', value: 'adminFilterable'},
92+
selectionSet: {
93+
kind: 'SelectionSet',
94+
selections: [{kind: 'Field', name: {kind: 'Name', value: 'enabled'}}],
95+
},
96+
},
97+
],
98+
},
99+
},
100+
{
101+
kind: 'Field',
102+
name: {kind: 'Name', value: 'validations'},
103+
selectionSet: {
104+
kind: 'SelectionSet',
105+
selections: [
106+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
107+
{kind: 'Field', name: {kind: 'Name', value: 'value'}},
108+
],
109+
},
110+
},
111+
],
112+
},
113+
},
114+
],
115+
} as unknown as DocumentNode<MetafieldForImportFragment, unknown>
116+
export const MetafieldDefinitions = {
117+
kind: 'Document',
118+
definitions: [
119+
{
120+
kind: 'OperationDefinition',
121+
operation: 'query',
122+
name: {kind: 'Name', value: 'metafieldDefinitions'},
123+
variableDefinitions: [
124+
{
125+
kind: 'VariableDefinition',
126+
variable: {kind: 'Variable', name: {kind: 'Name', value: 'ownerType'}},
127+
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'MetafieldOwnerType'}}},
128+
},
129+
{
130+
kind: 'VariableDefinition',
131+
variable: {kind: 'Variable', name: {kind: 'Name', value: 'after'}},
132+
type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}},
133+
},
134+
],
135+
selectionSet: {
136+
kind: 'SelectionSet',
137+
selections: [
138+
{
139+
kind: 'Field',
140+
name: {kind: 'Name', value: 'metafieldDefinitions'},
141+
arguments: [
142+
{
143+
kind: 'Argument',
144+
name: {kind: 'Name', value: 'ownerType'},
145+
value: {kind: 'Variable', name: {kind: 'Name', value: 'ownerType'}},
146+
},
147+
{kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '30'}},
148+
{
149+
kind: 'Argument',
150+
name: {kind: 'Name', value: 'after'},
151+
value: {kind: 'Variable', name: {kind: 'Name', value: 'after'}},
152+
},
153+
],
154+
selectionSet: {
155+
kind: 'SelectionSet',
156+
selections: [
157+
{
158+
kind: 'Field',
159+
name: {kind: 'Name', value: 'pageInfo'},
160+
selectionSet: {
161+
kind: 'SelectionSet',
162+
selections: [
163+
{kind: 'Field', name: {kind: 'Name', value: 'hasNextPage'}},
164+
{kind: 'Field', name: {kind: 'Name', value: 'endCursor'}},
165+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
166+
],
167+
},
168+
},
169+
{
170+
kind: 'Field',
171+
name: {kind: 'Name', value: 'nodes'},
172+
selectionSet: {
173+
kind: 'SelectionSet',
174+
selections: [
175+
{kind: 'FragmentSpread', name: {kind: 'Name', value: 'MetafieldForImport'}},
176+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
177+
],
178+
},
179+
},
180+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
181+
],
182+
},
183+
},
184+
],
185+
},
186+
},
187+
{
188+
kind: 'FragmentDefinition',
189+
name: {kind: 'Name', value: 'MetafieldForImport'},
190+
typeCondition: {kind: 'NamedType', name: {kind: 'Name', value: 'MetafieldDefinition'}},
191+
selectionSet: {
192+
kind: 'SelectionSet',
193+
selections: [
194+
{kind: 'Field', name: {kind: 'Name', value: 'key'}},
195+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
196+
{kind: 'Field', name: {kind: 'Name', value: 'namespace'}},
197+
{kind: 'Field', name: {kind: 'Name', value: 'description'}},
198+
{
199+
kind: 'Field',
200+
name: {kind: 'Name', value: 'type'},
201+
selectionSet: {
202+
kind: 'SelectionSet',
203+
selections: [
204+
{kind: 'Field', name: {kind: 'Name', value: 'category'}},
205+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
206+
],
207+
},
208+
},
209+
{
210+
kind: 'Field',
211+
name: {kind: 'Name', value: 'access'},
212+
selectionSet: {
213+
kind: 'SelectionSet',
214+
selections: [
215+
{kind: 'Field', name: {kind: 'Name', value: 'admin'}},
216+
{kind: 'Field', name: {kind: 'Name', value: 'storefront'}},
217+
{kind: 'Field', name: {kind: 'Name', value: 'customerAccount'}},
218+
],
219+
},
220+
},
221+
{
222+
kind: 'Field',
223+
name: {kind: 'Name', value: 'capabilities'},
224+
selectionSet: {
225+
kind: 'SelectionSet',
226+
selections: [
227+
{
228+
kind: 'Field',
229+
name: {kind: 'Name', value: 'adminFilterable'},
230+
selectionSet: {
231+
kind: 'SelectionSet',
232+
selections: [{kind: 'Field', name: {kind: 'Name', value: 'enabled'}}],
233+
},
234+
},
235+
],
236+
},
237+
},
238+
{
239+
kind: 'Field',
240+
name: {kind: 'Name', value: 'validations'},
241+
selectionSet: {
242+
kind: 'SelectionSet',
243+
selections: [
244+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
245+
{kind: 'Field', name: {kind: 'Name', value: 'value'}},
246+
],
247+
},
248+
},
249+
],
250+
},
251+
},
252+
],
253+
} as unknown as DocumentNode<MetafieldDefinitionsQuery, MetafieldDefinitionsQueryVariables>

0 commit comments

Comments
 (0)