Skip to content

I want to edit Hydrogen's codegen.ts to fetch the Admin API schema. #2275

Answered by graygilmore
ujike-ryota asked this question in Help
Discussion options

You must be logged in to vote

I was able to get it working by running graphql-codegen directly instead of going through Hydrogen's CLI command. One tweak you'll want to make:

- import {preset as adminApiPreset} from '@shopify/api-codegen-preset';
+ import {preset as adminApiPreset, ApiType} from '@shopify/api-codegen-preset';

 'adminapi.generated.d.ts': {
   preset: adminApiPreset,
+  presetConfig: {
+    apiType: ApiType.Admin,
+  },
   plugins: ['typescript'],
   schema: 'https://shopify.dev/admin-graphql-direct-proxy',
 },

I then ran npx graphql-codegen --config .graphqlrc.ts and successfully generated the types.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@ujike-ryota
Comment options

@jamalsoueidan
Comment options

@graygilmore
Comment options

Answer selected by ujike-ryota
@ujike-ryota
Comment options

Comment options

You must be logged in to vote
2 replies
@ujike-ryota
Comment options

@frandiox
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants