Skip to content

[graphql] support mjs, cts, and mts config files #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,22 @@ The plugin supports multiple configuration file formats. Here is a list of all t
- graphql.config.json
- graphql.config.js
- graphql.config.cjs
- graphql.config.mjs
- graphql.config.ts
- graphql.config.cts
- graphql.config.mts
- graphql.config.yaml
- graphql.config.yml
- .graphqlrc (YAML and JSON)
- .graphqlrc.json
- .graphqlrc.yaml
- .graphqlrc.yml
- .graphqlrc.js
- .graphqlrc.cjs
- .graphqlrc.mjs
- .graphqlrc.ts
- .graphqlrc.cts
- .graphqlrc.mts

### Yaml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ val LEGACY_CONFIG_NAMES: Set<String> = linkedSetOf(
)

const val GRAPHQL_CONFIG_TS = "graphql.config.ts"
const val GRAPHQL_CONFIG_CTS = "graphql.config.cts"
const val GRAPHQL_CONFIG_MTS = "graphql.config.mts"
const val GRAPHQL_CONFIG_JS = "graphql.config.js"
const val GRAPHQL_CONFIG_CJS = "graphql.config.cjs"
const val GRAPHQL_CONFIG_MJS = "graphql.config.mjs"

const val GRAPHQL_CONFIG_JSON = "graphql.config.json"
const val GRAPHQL_CONFIG_YAML = "graphql.config.yaml"
const val GRAPHQL_CONFIG_YML = "graphql.config.yml"

const val GRAPHQL_RC = ".graphqlrc"
const val GRAPHQL_RC_TS = ".graphqlrc.ts"
const val GRAPHQL_RC_CTS = ".graphqlrc.cts"
const val GRAPHQL_RC_MTS = ".graphqlrc.mts"
const val GRAPHQL_RC_JS = ".graphqlrc.js"
const val GRAPHQL_RC_CJS = ".graphqlrc.cjs"
const val GRAPHQL_RC_MJS = ".graphqlrc.mjs"

const val GRAPHQL_RC_JSON = ".graphqlrc.json"
const val GRAPHQL_RC_YAML = ".graphqlrc.yaml"
Expand All @@ -39,16 +45,22 @@ const val GRAPHQL_RC_YML = ".graphqlrc.yml"
@JvmField
val MODERN_CONFIG_NAMES: Set<String> = linkedSetOf(
GRAPHQL_CONFIG_TS,
GRAPHQL_CONFIG_CTS,
GRAPHQL_CONFIG_MTS,
GRAPHQL_CONFIG_JS,
GRAPHQL_CONFIG_CJS,
GRAPHQL_CONFIG_MJS,
GRAPHQL_CONFIG_JSON,
GRAPHQL_CONFIG_YAML,
GRAPHQL_CONFIG_YML,
// "graphql.config.toml",
GRAPHQL_RC,
GRAPHQL_RC_TS,
GRAPHQL_RC_CTS,
GRAPHQL_RC_MTS,
GRAPHQL_RC_JS,
GRAPHQL_RC_CJS,
GRAPHQL_RC_MJS,
GRAPHQL_RC_JSON,
GRAPHQL_RC_YAML,
GRAPHQL_RC_YML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GraphQLConfigLoader(private val project: Project) {
return when (file.extension) {
"json" -> readJson(file)
"yaml", "yml" -> readYml(file)
"js", "cjs", "ts" -> readJs(file)
"js", "cjs", "mjs", "ts", "cts", "mts" -> readJs(file)
else -> when (file.name) {
GRAPHQLCONFIG -> readJson(file)
GRAPHQL_RC -> readContentDependent(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private const val TIMEOUT = 15000

private val LOG = logger<GraphQLJavaScriptConfigLoader>()

private val EXTENSIONS = setOf("js", "ts", "cjs")
private val EXTENSIONS = setOf("js", "ts", "cjs", "mjs", "cts", "mts")

class GraphQLJavaScriptConfigLoader : GraphQLConfigCustomLoader {

Expand Down