Shortcode.ts 784 B

1234567891011121314151617181920212223242526272829
  1. import { HoppRESTRequest } from "@hoppscotch/data"
  2. import { runMutation } from "../GQLClient"
  3. import {
  4. CreateShortcodeDocument,
  5. CreateShortcodeMutation,
  6. CreateShortcodeMutationVariables,
  7. DeleteShortcodeDocument,
  8. DeleteShortcodeMutation,
  9. DeleteShortcodeMutationVariables,
  10. } from "../graphql"
  11. type DeleteShortcodeErrors = "shortcode/not_found"
  12. export const createShortcode = (request: HoppRESTRequest) =>
  13. runMutation<CreateShortcodeMutation, CreateShortcodeMutationVariables, "">(
  14. CreateShortcodeDocument,
  15. {
  16. request: JSON.stringify(request),
  17. }
  18. )
  19. export const deleteShortcode = (code: string) =>
  20. runMutation<
  21. DeleteShortcodeMutation,
  22. DeleteShortcodeMutationVariables,
  23. DeleteShortcodeErrors
  24. >(DeleteShortcodeDocument, {
  25. code,
  26. })