How to create types GraphQL in extensions on this template GitHub - Shopify/shopify-app-template-remix?
It doesn’t work with this default configuration. schema.graphql
has no effect either
// .graphqlrc.ts
import fs from 'fs'
import { LATEST_API_VERSION } from '@shopify/shopify-api'
import { shopifyApiProject, ApiType } from '@shopify/api-codegen-preset'
import type { IGraphQLConfig } from 'graphql-config'
function getConfig() {
const config: IGraphQLConfig = {
projects: {
default: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: LATEST_API_VERSION,
documents: ['./src/**/*.{js,ts,jsx,tsx}', './src/.server/**/*.{js,ts,jsx,tsx}'],
outputDir: './src/shared/lib/utility-types/graphql',
}),
},
}
let extensions: string[] = []
try {
extensions = fs.readdirSync('./extensions')
} catch {
// ignore if no extensions
}
for (const entry of extensions) {
const extensionPath = `./extensions/${entry}`
const schema = `${extensionPath}/schema.graphql`
if (!fs.existsSync(schema)) {
continue
}
config.projects[entry] = {
schema,
documents: [`${extensionPath}/**/*.graphql`],
}
}
return config
}
const config = getConfig()
export default config