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

More detail on how to create webhooks #275

Closed
ivanakcheurov opened this issue Aug 14, 2023 · 1 comment
Closed

More detail on how to create webhooks #275

ivanakcheurov opened this issue Aug 14, 2023 · 1 comment
Assignees

Comments

@ivanakcheurov
Copy link

ivanakcheurov commented Aug 14, 2023

What I'm trying to achieve

Build a Saleor app with webhooks.

Problem Statement

Currently, to maintain type-safety, developers are encouraged to define the payload from the API, which should ideally be imported from the generated GraphQL code. However, locating and extracting this generated code can be a tedious process.

Describe a proposed solution

Smart solution and better DX with pregenerated code inside saleor-app-sdk

Since saleor-app-sdk is built against a specific version of Saleor, please generate the generated GraphQL code as part of saleor-app-sdk and allow direct import like import { OrderPayload } from "@saleor/app-sdk/handlers/payloads";


If payload from API means the query field of the webhook and is hard to pregen and bake into saleor-app-sdk then at least the lazy solution (below) would already improve DX somewhat.

Lazy solution - a faster way to read Saleor's doc and build a webhook:

To be type-safe, define payload from API. This should be imported from generated GraphQL code

Please provide a link to a page where it describes what is the most common, easiest and fastest way to get the generated GraphQL code and where I can find the type-safe ready-for-import TS code within the generated GraphQL code.

@lkostrowski
Copy link
Member

Hey, as I little written here I don't think app-sdk is a good place to do that. It will introduce a circular dependency - App SDK needs app, to provide a generated queries, but App needs SDK to generate schemas from them

I understand its not perfect at the moment - you need to provide the fragment manually and its not runtime safe (however graphQL should be enough IMO).

But the fact that every app defines its unique set of queries, subscriptions, mutations - we can't pre-build them in sdk

You can modify you graphql codegen config and use package like this to ensure runtime safety

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

2 participants