-
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix middleware and integration test for it
- Loading branch information
1 parent
99cdd6b
commit ba1889d
Showing
21 changed files
with
812 additions
and
814 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM node:20 | ||
|
||
WORKDIR /app | ||
|
||
COPY ./graphql-voyager-*.tgz graphql-voyager.tgz | ||
|
||
COPY ./example/express-server ./example/express-server | ||
|
||
WORKDIR example/express-server | ||
RUN npm install | ||
RUN npm test | ||
|
||
EXPOSE 9090 | ||
CMD npm start |
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,23 @@ | ||
import * as express from 'express'; | ||
import { createHandler } from 'graphql-http/lib/use/express'; | ||
import { express as voyagerMiddleware } from 'graphql-voyager/middleware'; | ||
|
||
import { schema } from './schema'; | ||
|
||
const PORT = 9090; | ||
const app = express(); | ||
|
||
app.use('/graphql', createHandler({ schema })); | ||
app.use( | ||
'/voyager', | ||
voyagerMiddleware({ | ||
endpointUrl: '/graphql', | ||
displayOptions: { | ||
sortByAlphabet: true, | ||
}, | ||
}), | ||
); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Started on http://localhost:${PORT}/voyager`); | ||
}); |
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,19 @@ | ||
{ | ||
"private": "true", | ||
"description": "An example using GraphQL-Voyager", | ||
"scripts": { | ||
"start": "ts-node index.ts", | ||
"test": "tsc" | ||
}, | ||
"dependencies": { | ||
"express": "4.16.3", | ||
"graphql": "16.5.0", | ||
"graphql-http": "1.22.1", | ||
"graphql-voyager": "../../graphql-voyager.tgz" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "4.17.21", | ||
"ts-node": "10.9.2", | ||
"typescript": "4.9.5" | ||
} | ||
} |
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,103 @@ | ||
import { buildSchema } from 'graphql'; | ||
|
||
export const schema = buildSchema(` | ||
enum TestEnum { | ||
"A rosy color" | ||
RED | ||
"The color of martians and slime" | ||
GREEN | ||
"A feeling you might have if you can't use GraphQL" | ||
BLUE | ||
} | ||
input TestInput { | ||
string: String | ||
int: Int | ||
float: Float | ||
boolean: Boolean | ||
id: ID | ||
enum: TestEnum | ||
object: TestInput | ||
# List | ||
listString: [String] | ||
listInt: [Int] | ||
listFloat: [Float] | ||
listBoolean: [Boolean] | ||
listID: [ID] | ||
listEnum: [TestEnum] | ||
listObject: [TestInput] | ||
} | ||
"The interface" | ||
interface TestInterface { | ||
"Common name string." | ||
name: String | ||
} | ||
type First implements TestInterface { | ||
"Common name string for First." | ||
name: String | ||
first: [TestInterface] | ||
} | ||
type Second implements TestInterface { | ||
"Common name string for Second." | ||
name: String | ||
second: [TestInterface] | ||
} | ||
union TestUnion = First | Second | ||
type Test { | ||
"\`test\` field from \`Test\` type." | ||
test: Test | ||
"> union field from Test type, block-quoted." | ||
union: TestUnion | ||
"id field from Test type." | ||
id: ID | ||
"Is this a test schema? Sure it is." | ||
isTest: Boolean | ||
hasArgs( | ||
string: String | ||
int: Int | ||
float: Float | ||
boolean: Boolean | ||
id: ID | ||
enum: TestEnum | ||
object: TestInput | ||
# List | ||
listString: [String] | ||
listInt: [Int] | ||
listFloat: [Float] | ||
listBoolean: [Boolean] | ||
listID: [ID] | ||
listEnum: [TestEnum] | ||
listObject: [TestInput] | ||
): String | ||
} | ||
"This is a simple mutation type" | ||
type MutationType { | ||
"Set the string field" | ||
setString(value: String): String | ||
} | ||
"This is a simple subscription type" | ||
type SubscriptionType { | ||
"Subscribe to the test type" | ||
subscribeToTest(id: String): Test | ||
} | ||
schema { | ||
query: Test | ||
mutation: MutationType | ||
subscription: SubscriptionType | ||
} | ||
`); |
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,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"noEmit": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"target": "es2021" | ||
}, | ||
"include": ["./index.ts"], | ||
"ts-node": { | ||
"compilerOptions": { | ||
"module": "CommonJS" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.