Skip to content

Commit

Permalink
Refactor/generate resolvers from sources (#4)
Browse files Browse the repository at this point in the history
* ♻️ refactor resolvers types generation from swaggers

* 🔥 remove unsued files and improve refactoring

---------

Co-authored-by: Mbaye THIAM <[email protected]>
  • Loading branch information
mbthiam88 and Mbaye THIAM authored Apr 3, 2024
1 parent ead29e1 commit 2cb5186
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 535 deletions.
18 changes: 8 additions & 10 deletions packages/graphql-mesh/.meshrc.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { Config } from '@graphql-mesh/types/typings/config'
import {
openapiSources,
additionalTypeDefs,
resolvers,
defaultConfig,
othersSources
} from './setup'
import ConfigFromSwaggers from './utils/ConfigFromSwaggers'

const configFromSwaggers = new ConfigFromSwaggers()
const { defaultConfig, additionalResolvers, additionalTypeDefs, sources } =
configFromSwaggers.getMeshConfigFromSwaggers()

const config = <Config>{
...defaultConfig,
Expand All @@ -15,9 +13,9 @@ const config = <Config>{
{ 'directive-no-auth': {} },
...(defaultConfig.transforms || [])
],
sources: [...openapiSources, ...othersSources],
additionalTypeDefs: [...(defaultConfig.additionalTypeDefs || []), additionalTypeDefs],
additionalResolvers: [...(defaultConfig.additionalResolvers || []), resolvers]
sources: [...sources],
additionalTypeDefs: [...(defaultConfig.additionalTypeDefs || []), ...additionalTypeDefs],
additionalResolvers: [...(defaultConfig.additionalResolvers || []), additionalResolvers]
}

export default config
3 changes: 0 additions & 3 deletions packages/graphql-mesh/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/graphql-mesh/scripts/download-sources.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileOrUrl, DefaultLogger } from '@graphql-mesh/utils'
import { getConfig } from '../helpers/config'
import { getConfig } from '../utils/config'
import { writeFileSync, existsSync, mkdirSync } from 'node:fs'
import { fetch } from '@whatwg-node/fetch'
const logger = new DefaultLogger()
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-mesh/serve.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer } from 'node:http'
import { createBuiltMeshHTTPHandler } from './.mesh'
import { getConfig } from './helpers'
import { getConfig } from './utils/config'
const config = getConfig() || {}

const PORT = config.serve?.port ?? 4000
Expand Down
Loading

0 comments on commit 2cb5186

Please sign in to comment.