-
Notifications
You must be signed in to change notification settings - Fork 331
Typescript types #79
Comments
Are you referring to https://github.com/Shopify/storefront-api-examples/blob/master/angular-graphql-client/src/app/shared/services/types.ts? The Angular example was an external contribution unfortunately. I don't know how the contributor generated it originally. I imagine (and hope) it was automated somehow though! |
@swalkinshaw the types.ts file you mentioned still just has the GraphQL text descriptors (with types.ts probably hand-made by a contributor from the original types.js file which I'm guessing was procedurally generated by someone at Shopify). These files are soooo close to what is needed for strongly-typed access to the data, but it's just exactly not usable for that today. What we need are either class or interface descriptions like
where what the types.js/types.ts files contain are string-based lines like
The content is incredibly close, just some minor grepping and editing to convert. The problem is there is some shopify-generated magic in the types.js/types.ts text that I can't figure out what to do with, for example all of the "OBJECT" type descriptors contain lines like Given that GraphQL is at the core a strongly-typed API, and given that you're a tiny, tiny bit of search-and-replace from having your interface fully typed, it would be a huge help to all of us that do use typescript if you folks could do that tiny last step and publish this file as an actual types.d.ts file, since its soooo close to being one already. |
This is probably something we'd have to automate in another repository. I personally don't have any experience with TS. Are there existing tools to generate the types from a GraphQL API? Seems like something should exist since that's a benefit that a spec like GraphQL provides. |
Just checking if Shopify has moved towards typescript in the past six months |
@swalkinshaw and @yoDon If this is still interesting, I created a package that includes all Typescript typings for Shopify Storefront API. |
Wow its been 2 years but the quest remains the same, its not easy to find a shopify admin api in typescript |
The existing arc/types.js file is sooooo close to being a typescript *.d.ts file.
I spent about an hour trying to hand edit types.js into a list of type definitions but didn't quite understand some of the types and structures well enough to do so (for example what methods should a type the implements node receive?). I'm also guessing the existing types.js file was procedurally generated, in which case it would be much faster and more maintainable for someone inside Shopify to update the generator once, but even if it was hand edited types.d.ts would still be an incredibly achievable super high value asset to the community.
What's the best way to go forward - should I take a stab at a hand-edited PR or would that be rejected because types.js is procedurally generated and types.d.ts needs to be as well?
The text was updated successfully, but these errors were encountered: