1
- const fs = require ( 'node:fs' ) ;
2
- const apiVersion = require ( "@shopify/shopify-app-remix" ) . LATEST_API_VERSION ;
1
+ import fs from "fs" ;
2
+ import { LATEST_API_VERSION } from "@shopify/shopify-api" ;
3
+ import { shopifyApiProject , ApiType } from "@shopify/api-codegen-preset" ;
3
4
4
5
function getConfig ( ) {
5
- const config = {
6
- projects : {
7
- shopifyAdminApi : {
8
- schema : `https://shopify.dev/admin-graphql-direct-proxy/${ apiVersion } ` ,
9
- documents : [ './app/**/*.{graphql,js,ts,jsx,tsx}' ]
10
- }
11
- }
12
- }
6
+ const config = {
7
+ projects : {
8
+ default : shopifyApiProject ( {
9
+ apiType : ApiType . Admin ,
10
+ apiVersion : LATEST_API_VERSION ,
11
+ documents : [ "./app/**/*.{js,jsx}" , "./app/.server/**/*.{js,jsx}" ] ,
12
+ outputDir : "./app/types" ,
13
+ } ) ,
14
+ } ,
15
+ } ;
13
16
14
- let extensions = [ ]
15
- try {
16
- extensions = fs . readdirSync ( ' ./extensions' ) ;
17
- } catch {
18
- // ignore if no extensions
19
- }
17
+ let extensions = [ ] ;
18
+ try {
19
+ extensions = fs . readdirSync ( " ./extensions" ) ;
20
+ } catch {
21
+ // ignore if no extensions
22
+ }
20
23
21
- for ( const entry of extensions ) {
22
- const extensionPath = `./extensions/${ entry } ` ;
23
- const schema = `${ extensionPath } /schema.graphql` ;
24
- if ( ! fs . existsSync ( schema ) ) {
25
- continue ;
26
- }
27
- config . projects [ entry ] = {
28
- schema,
29
- documents : [ `${ extensionPath } /input.graphql` ]
30
- }
24
+ for ( const entry of extensions ) {
25
+ const extensionPath = `./extensions/${ entry } ` ;
26
+ const schema = `${ extensionPath } /schema.graphql` ;
27
+ if ( ! fs . existsSync ( schema ) ) {
28
+ continue ;
31
29
}
30
+ config . projects [ entry ] = {
31
+ schema,
32
+ documents : [ `${ extensionPath } /**/*.graphql` ] ,
33
+ } ;
34
+ }
32
35
33
- return config ;
36
+ return config ;
34
37
}
35
38
36
- module . exports = getConfig ( ) ;
39
+ const config = getConfig ( ) ;
40
+
41
+ export default config ;
0 commit comments