Skip to content

Commit

Permalink
async tsimport > sync tsimport
Browse files Browse the repository at this point in the history
  • Loading branch information
mishushakov authored and ryoppippi committed Jun 17, 2023
1 parent b7aa1c3 commit ad2b955
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ClientOptions = {
headers?: HeadersInit
defaults?: ReactClientDefaults
cacheOptions?: CacheOptions
fetch?: typeof globalThis.fetch
}

// TODO
Expand All @@ -33,6 +34,7 @@ function createQueryFetcher (options: ClientOptions): QueryFetcher {
{ query, variables, operationName },
fetchOptions
) {
const fetch = options.fetch ?? globalThis.fetch
const response = await fetch(options.url, {
method: "POST",
headers: {
Expand Down
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { importTSmodule } from '@mishushakov/ts-load'
import { importTSmoduleSync } from '@mishushakov/ts-load'
import { resolve } from 'path'
import serialize from 'babel-literal-to-ast'
import { createGeneratedSchema, createScalarsEnumsHash } from './utils'
Expand All @@ -12,11 +12,11 @@ export default function GarphGQtyPlugin(_, { clientConfig }) {
path.node.specifiers = []
}
},
async CallExpression(path, state) {
CallExpression(path, state) {
if (state.file.opts.filename !== resolve(clientConfig)) return
if (path.node.callee.name !== 'createClient') return

const module = await importTSmodule(state.file.opts.filename)
const module = importTSmoduleSync(state.file.opts.filename)
const schema = module.compiledSchema
const generatedSchema = createGeneratedSchema(schema)
const scalarsEnumsHash = createScalarsEnumsHash(schema)
Expand Down

0 comments on commit ad2b955

Please sign in to comment.