Created
May 23, 2020 01:17
-
-
Save KTruong008/5e1ad7b9d86b14ac0e20e0a411488bce to your computer and use it in GitHub Desktop.
A first look at hasura example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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