-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
apollo-server-errors
import for typescript projects using apol…
- Loading branch information
1 parent
817edc6
commit 2f1aa22
Showing
13 changed files
with
138 additions
and
31 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { | ||
TypeInfo, | ||
ValidationContext, | ||
visit, | ||
visitWithTypeInfo | ||
} = require('graphql') | ||
const QueryValidationVisitor = require('./query-validation-visitor.js') | ||
|
||
function validateQuery (schema, query, variables, operationName, pluginOptions = {}) { | ||
const typeInfo = new TypeInfo(schema) | ||
|
||
const errors = [] | ||
const context = new ValidationContext( | ||
schema, | ||
query, | ||
typeInfo, | ||
(error) => errors.push(error) | ||
) | ||
|
||
const visitor = new QueryValidationVisitor(context, { | ||
variables, | ||
operationName, | ||
pluginOptions | ||
}) | ||
|
||
visit(query, visitWithTypeInfo(typeInfo, visitor)) | ||
|
||
return errors | ||
} | ||
|
||
module.exports = { validateQuery } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"test-apollo-plugin": "standard && nyc --reporter=html --reporter=text --reporter=lcov mocha test/**/testsuite-apollo-plugin.js", | ||
"test-apollo4-plugin": "standard && nyc --reporter=html --reporter=text --reporter=lcov mocha test/**/testsuite-apollo4-plugin.js", | ||
"test-envelop-plugin": "standard && nyc --reporter=html --reporter=text --reporter=lcov mocha test/**/testsuite-envelop-plugin.js", | ||
"test-typescript": "tsc --project tsconfig.apollo4.json && tsc --project tsconfig.apollo.json", | ||
"test-validation-rule-express-graphql": "standard && nyc --reporter=html --reporter=text --reporter=lcov mocha test/**/testsuite-validation-rule-express-graphql.js" | ||
}, | ||
"author": "James Mortemore ([email protected])", | ||
|
@@ -34,16 +35,17 @@ | |
"constraint" | ||
], | ||
"devDependencies": { | ||
"apollo-server-express": "3.13.0", | ||
"@apollo/server": "4.9.5", | ||
"@graphql-yoga/node": "2.13.13", | ||
"apollo-server-express": "3.13.0", | ||
"coveralls": "3.1.1", | ||
"express": "4.21.0", | ||
"graphql": "16.6.0", | ||
"mocha": "10.7.3", | ||
"nyc": "15.1.0", | ||
"standard": "16.0.4", | ||
"supertest": "6.3.4", | ||
"@graphql-yoga/node": "2.13.13" | ||
"typescript": "^5.5.3" | ||
}, | ||
"dependencies": { | ||
"@graphql-tools/schema": "^9.0.0", | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
import { constraintDirective, constraintDirectiveTypeDefs } from 'graphql-constraint-directive'; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { constraintDirectiveTypeDefs, createApollo4QueryValidationPlugin } from 'graphql-constraint-directive/apollo4'; | ||
|
||
export { constraintDirectiveTypeDefs, createApollo4QueryValidationPlugin }; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const errorFn: () => string = { | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": ".", | ||
"declaration": false, | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"importHelpers": true, | ||
"target": "es2015", | ||
"module": "esnext", | ||
"lib": [ | ||
"es2020", | ||
], | ||
"checkJs": true, | ||
"skipLibCheck": true, | ||
"skipDefaultLibCheck": true, | ||
"paths": { | ||
"graphql-constraint-directive": [ | ||
"index.js", | ||
"index.d.ts", | ||
] | ||
} | ||
}, | ||
"include": [ | ||
"./test/typescript/apollo.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"tmp" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": ".", | ||
"declaration": false, | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"importHelpers": true, | ||
"target": "es2015", | ||
"module": "esnext", | ||
"lib": [ | ||
"es2020", | ||
], | ||
"checkJs": true, | ||
"skipLibCheck": true, | ||
"skipDefaultLibCheck": true, | ||
"paths": { | ||
"graphql-constraint-directive/apollo4": [ | ||
"apollo4.js", | ||
"apollo4.d.ts", | ||
], | ||
"apollo-server-errors": [ | ||
"./test/typescript/error.ts" | ||
] | ||
} | ||
}, | ||
"include": [ | ||
"./test/typescript/apollo4.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"tmp" | ||
] | ||
} |