Skip to content

Instantly share code, notes, and snippets.

@KTruong008
Created May 23, 2020 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KTruong008/5e1ad7b9d86b14ac0e20e0a411488bce to your computer and use it in GitHub Desktop.
Save KTruong008/5e1ad7b9d86b14ac0e20e0a411488bce to your computer and use it in GitHub Desktop.
A first look at hasura example
export const promotionsFetchEpic = (
action$: ActionsObservable<PayloadAction>,
state$: StateObservable<StoreState>,
): Observable<PayloadAction> =>
action$.pipe(
filter((action) => action.type === appDataFetchSuccess.toString()),
asyncRequest(
promotionsFetchStart.toString(),
promotionsFetchSuccess.toString(),
promotionsFetchError.toString(),
(action: PayloadAction) => {
const shopOrgin = selectShopOrigin(state$.value);
return hasuraGraphqlRequest(
`
query PromotionsFetch {
promotion(where: {shop_origin: {_eq: "${shopOrgin}"}}) {
promotion_id
promotion_type
countdown_promotion {
countdown_timer_message
countdown_timer_message_font_size
...
}
text_promotion {
custom_message
...
}
promotion_products {
product_id
promotion_id
product {
...
}
}
}
}
`,
{},
selectJwt(state$.value),
);
},
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment