Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose RemixRestClient and GraphQLClient types for @shopify/shopify-app-remix #633

Open
geongeorge opened this issue Feb 6, 2024 · 5 comments

Comments

@geongeorge
Copy link

Overview/summary

I want to pass my admin rest or graphql api client in a seperate server file in remix js. But the types are not exposed.

export const loader = async ({ request }: LoaderFunctionArgs) => {
  const { session, admin } = await authenticate.admin(request);

  const themes = await getThemes(session, admin.rest);

  return json({ themes });
};

I want to do something like this in another file but I do not see any export from the library for RestClient or GraphqlClients

export async function getThemes(session: Session, rest: RemixRestClient) {
  
   const themes = await rest.resources.Theme.all({ session: session });

  return themes;
}

Note

If this is a generic type which is generated when running shopifyApp({..}) It will be also great if this can be accessed through the returned object so I can reexport from the shopify.server.ts file

@matteodepalo
Copy link
Contributor

Hi @geongeorge, thank you for opening this issue. I've put it in the backlog so that my team can consider it.

@geongeorge
Copy link
Author

geongeorge commented Feb 7, 2024

Hi @matteodepalo Because module resolution is not node in the remix app, I'm not able to import types for shopify resources as well from the api. I cannot get the Theme, Product, Etc type from this package as well.

export async function getJobs(shopName: string, themes: Theme) {
  ...
}

@geongeorge
Copy link
Author

geongeorge commented Mar 5, 2024

I managed to extract the types from the shopify.server.ts file like so. Using it in our custom starter:

/* Getting types */
export type AdminMain = Awaited<ReturnType<typeof authenticate.admin>>;

export type AdminApiContext = AdminMain["admin"];
export type AdminApiSession = AdminMain["session"];

export type AdminGraphqlClient = AdminApiContext["graphql"];
export type AdminRestClient = AdminApiContext["rest"];

Copy link
Contributor

github-actions bot commented May 5, 2024

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

@github-actions github-actions bot added the Stale label May 5, 2024
@RobRoseKnows
Copy link

This has been very frustrating. I was trying to adapt your starter QRCode example from JavaScript to TypeScript, and it means I need types that simply are not exposed from the package. https://shopify.dev/docs/apps/getting-started/build-qr-code-app

@github-actions github-actions bot removed the Stale label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants