-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: package is now ESM BREAKING CHANGE: package is now ESM * fix(deps): bump execa * fix: correct `fs` import * fix: replace usage of `require()` * style: prettier * fix: update execa import * test: remove default export tests
- Loading branch information
Showing
10 changed files
with
147 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module.exports = { | ||
validate: require('./lib/validate'), | ||
schema: { | ||
get idl () { | ||
const join = require('path').join | ||
return require('fs').readFileSync(join(__dirname, 'schema.graphql'), 'utf8') | ||
}, | ||
json: require('./schema.json') | ||
} | ||
import { readFileSync } from 'node:fs'; | ||
import validate from './lib/validate.js'; | ||
|
||
export { validate }; | ||
export const schema = { | ||
get idl () { | ||
return readFileSync(new URL('./schema.graphql', import.meta.url), 'utf8') | ||
}, | ||
json: JSON.parse(readFileSync(new URL('./schema.json', import.meta.url), 'utf8')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
module.exports = validateQuery; | ||
export default validateQuery; | ||
|
||
const graphql = require("graphql"); | ||
const gql = require("graphql-tag"); | ||
import { readFileSync } from "node:fs"; | ||
import { buildClientSchema, validate } from "graphql"; | ||
import gql from "graphql-tag"; | ||
|
||
const schema = graphql.buildClientSchema(require("../schema.json")); | ||
const schema = buildClientSchema( | ||
JSON.parse(readFileSync(new URL("../schema.json", import.meta.url), "utf8")), | ||
); | ||
|
||
function validateQuery(query) { | ||
return graphql.validate(schema, gql(query)); | ||
return validate(schema, gql(query)); | ||
} |
Oops, something went wrong.