Skip to content

Commit

Permalink
fix(apollo-client): get build working
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcalise committed Oct 15, 2023
1 parent ee9dc06 commit 93fd2a4
Show file tree
Hide file tree
Showing 3 changed files with 1,719 additions and 3,550 deletions.
14 changes: 8 additions & 6 deletions lib/reactotron-apollo-client/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import resolve from "rollup-plugin-node-resolve"
import babel from "rollup-plugin-babel"
import filesize from "rollup-plugin-filesize"
import minify from "rollup-plugin-babel-minify"
// import minify from "rollup-plugin-babel-minify"

const pkg = require("./package.json")

Expand All @@ -28,11 +28,13 @@ export default {
plugins: [
resolve({ extensions: [".ts"] }),
babel({ extensions: [".ts"], runtimeHelpers: true }),
process.env.NODE_ENV === "production"
? minify({
comments: false,
})
: null,
// TODO fix minification via rollup-plugin-terser?
// rollout-plugin-babel-minify is deprecated and causing build to fail
// process.env.NODE_ENV === "production"
// ? minify({
// comments: false,
// })
// : null,
filesize(),
],
external: ["@apollo/client", "reactotron-core-client", "graphql"],
Expand Down
84 changes: 43 additions & 41 deletions lib/reactotron-apollo-client/src/reactotron-apollo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type MutationData = {
body: string | undefined
}

type Callback = () => any
// type Callback = () => any

type ArrayOfQuery = Array<QueryData>
type ArrayOfMutations = Array<MutationData>
Expand All @@ -59,45 +59,46 @@ type ApolloClientState = {
cache: object
}

type RawMutationBody = {
id: string
name: string | null
body: string
variables: object
}

type RawQueryBody = {
id: string
name: string | null
cachedData: object
}

type RawData = {
id: string
lastUpdateAt: Date
queries: ArrayOfQuery
mutations: ArrayOfMutations
cache: Array<BlockType>
}

type Data = {
id: string
lastUpdateAt: Date
queries: Array<BlockType>
mutations: Array<BlockType>
cache: Array<BlockType>
}

type BlockType = {
id?: string
operationType?: string
name?: string | null
blocks?: Array<{
blockType: string
blockLabel: string
blockValue: any
}>
}
// TODO utilize when we do Queries and Mutations
// type RawMutationBody = {
// id: string
// name: string | null
// body: string
// variables: object
// }

// type RawQueryBody = {
// id: string
// name: string | null
// cachedData: object
// }

// type RawData = {
// id: string
// lastUpdateAt: Date
// queries: ArrayOfQuery
// mutations: ArrayOfMutations
// cache: Array<BlockType>
// }

// type Data = {
// id: string
// lastUpdateAt: Date
// queries: Array<BlockType>
// mutations: Array<BlockType>
// cache: Array<BlockType>
// }

// type BlockType = {
// id?: string
// operationType?: string
// name?: string | null
// blocks?: Array<{
// blockType: string
// blockLabel: string
// blockValue: any
// }>
// }

let tick = 0

Expand All @@ -119,6 +120,7 @@ function getQueries(queryMap: Map<string, RawQueryData>): ArrayOfQuery {
const queries: ArrayOfQuery = []

if (queryMap) {
// @ts-expect-error Type 'IterableIterator<RawQueryData>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher
;[...queryMap.values()].forEach(
({ document, variables, observableQuery, diff, lastDiff }, queryId) => {
if (document && observableQuery) {
Expand Down Expand Up @@ -194,7 +196,7 @@ async function getCurrentState(client: ApolloClientType): Promise<ApolloClientSt
}

function debounce(func: (...args: any) => any, timeout = 500): () => any {
let timer: NodeJS.Timeout
let timer
return (...args) => {
clearTimeout(timer)
timer = setTimeout(() => {
Expand Down
Loading

0 comments on commit 93fd2a4

Please sign in to comment.