"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-app/newstore/GQLSession.ts" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

GQLSession.ts  (hoppscotch-2.2.1):GQLSession.ts  (hoppscotch-3.0.0)
import { distinctUntilChanged, pluck } from "rxjs/operators" import { distinctUntilChanged, pluck } from "rxjs/operators"
import { GQLHeader, HoppGQLRequest, makeGQLRequest } from "@hoppscotch/data" import {
GQLHeader,
HoppGQLRequest,
makeGQLRequest,
HoppGQLAuth,
} from "@hoppscotch/data"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore" import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { useStream } from "~/helpers/utils/composables" import { useStream } from "@composables/stream"
type GQLSession = { type GQLSession = {
request: HoppGQLRequest request: HoppGQLRequest
schema: string schema: string
response: string response: string
} }
export const defaultGQLSession: GQLSession = { export const defaultGQLSession: GQLSession = {
request: makeGQLRequest({ request: makeGQLRequest({
name: "Untitled request", name: "Untitled request",
skipping to change at line 29 skipping to change at line 34
}`, }`,
query: `query Request { query: `query Request {
method method
url url
headers { headers {
key key
value value
} }
} }
`, `,
auth: {
authType: "none",
authActive: true,
},
}), }),
schema: "", schema: "",
response: "", response: "",
} }
const dispatchers = defineDispatchers({ const dispatchers = defineDispatchers({
setSession(_: GQLSession, { session }: { session: GQLSession }) { setSession(_: GQLSession, { session }: { session: GQLSession }) {
return session return session
}, },
setName(curr: GQLSession, { newName }: { newName: string }) { setName(curr: GQLSession, { newName }: { newName: string }) {
skipping to change at line 115 skipping to change at line 124
...curr.request, ...curr.request,
variables: newVariables, variables: newVariables,
}, },
} }
}, },
setResponse(_: GQLSession, { newResponse }: { newResponse: string }) { setResponse(_: GQLSession, { newResponse }: { newResponse: string }) {
return { return {
response: newResponse, response: newResponse,
} }
}, },
setAuth(curr: GQLSession, { newAuth }: { newAuth: HoppGQLAuth }) {
return {
request: {
...curr.request,
auth: newAuth,
},
}
},
}) })
export const gqlSessionStore = new DispatchingStore( export const gqlSessionStore = new DispatchingStore(
defaultGQLSession, defaultGQLSession,
dispatchers dispatchers
) )
export function setGQLURL(newURL: string) { export function setGQLURL(newURL: string) {
gqlSessionStore.dispatch({ gqlSessionStore.dispatch({
dispatcher: "setURL", dispatcher: "setURL",
skipping to change at line 226 skipping to change at line 243
export function useGQLRequestName() { export function useGQLRequestName() {
return useStream(gqlName$, gqlSessionStore.value.request.name, (newName) => { return useStream(gqlName$, gqlSessionStore.value.request.name, (newName) => {
gqlSessionStore.dispatch({ gqlSessionStore.dispatch({
dispatcher: "setName", dispatcher: "setName",
payload: { newName }, payload: { newName },
}) })
}) })
} }
export function setGQLAuth(newAuth: HoppGQLAuth) {
gqlSessionStore.dispatch({
dispatcher: "setAuth",
payload: {
newAuth,
},
})
}
export const gqlName$ = gqlSessionStore.subject$.pipe( export const gqlName$ = gqlSessionStore.subject$.pipe(
pluck("request", "name"), pluck("request", "name"),
distinctUntilChanged() distinctUntilChanged()
) )
export const gqlURL$ = gqlSessionStore.subject$.pipe( export const gqlURL$ = gqlSessionStore.subject$.pipe(
pluck("request", "url"), pluck("request", "url"),
distinctUntilChanged() distinctUntilChanged()
) )
export const gqlQuery$ = gqlSessionStore.subject$.pipe( export const gqlQuery$ = gqlSessionStore.subject$.pipe(
pluck("request", "query"), pluck("request", "query"),
skipping to change at line 251 skipping to change at line 277
) )
export const gqlHeaders$ = gqlSessionStore.subject$.pipe( export const gqlHeaders$ = gqlSessionStore.subject$.pipe(
pluck("request", "headers"), pluck("request", "headers"),
distinctUntilChanged() distinctUntilChanged()
) )
export const gqlResponse$ = gqlSessionStore.subject$.pipe( export const gqlResponse$ = gqlSessionStore.subject$.pipe(
pluck("response"), pluck("response"),
distinctUntilChanged() distinctUntilChanged()
) )
export const gqlAuth$ = gqlSessionStore.subject$.pipe(
pluck("request", "auth"),
distinctUntilChanged()
)
 End of changes. 6 change blocks. 
2 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)