本文整理汇总了TypeScript中express-graphql.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: require
const express = require("express")
const graphqlHTTP = require("express-graphql")
import { buildSchema } from "graphql"
const schema = buildSchema(`
type Query {
hello: String
}
`)
const root = {
hello: () => "Hello world!",
}
const app = express()
export default app
app.use(
"/graphql",
graphqlHTTP({
graphiql: true,
rootValue: root,
schema,
})
)
export function start(): any {
// tslint:disable:no-console
app.listen(4000, () => console.log("Now browse to localhost:4000/graphql"))
}
开发者ID:pact-foundation,项目名称:pact-js,代码行数:30,代码来源:provider.ts
示例2: startPublications
export function startPublications() {
const mode = process.env.NODE_ENV || "DEVELOPMENT";
const app = express();
if (mode.toUpperCase() === "DEVELOPMENT") {
const compiler = webpack(webpackConfig as webpack.Configuration);
app.use(
webpackDevMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
})
);
app.use(webpackHotMiddleware(compiler));
app.use("/playground", graphqlPlayground({ endpoint: "/graphql" }));
} else {
const publicPath = path.resolve(__dirname, "../public");
app.use(express.static(publicPath));
app.get("*", (req, res) =>
res.sendFile(path.resolve(publicPath, "index.html"))
);
}
app.use(jwt(jwtConfig));
app.use(
"/graphql",
graphqlHttp(request => ({
schema,
context: { user: request.user },
}))
);
app.use(onAuthError);
app.get("/documents/:id/pdf", documentPdfHandler);
app.listen(PORT, () => {
console.log(`Publications started on port ${PORT}.`);
});
}
开发者ID:carlospaelinck,项目名称:publications-js,代码行数:35,代码来源:index.ts
示例3: function
module.exports = function (app) {
let schema = buildSchema(`
type Query {
hello: String
}
`);
let root = { hello: () => 'Hello world!' };
app.use('/hello', graphqlHTTP({
schema: HelloService.schema,
rootValue: HelloService.rootValue,
graphiql: true,
}));
};
开发者ID:toannvbk93,项目名称:goemon,代码行数:15,代码来源:hello.ts
示例4: graphqlHTTP
(async () => {
try {
db = await MongoClient.connect(process.env.MONGO_URL);
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true,
pretty: true,
context: {
db
}
}));
app.get('*', function (req: express.Request, res: express.Response) {
res.sendFile(__dirname + '/public/index.html');
});
app.listen(3000, () => console.log('Listening on port 3000'));
// generate schema.json
let result: GraphQLResult = await graphql(schema, graphqlUtils.introspectionQuery);
if (result.errors) {
console.error(
'ERROR introspecting schema: ', result
);
} else {
fs.writeFile('./data/schema.json', JSON.stringify(result, null, 2), err => {
if (err) {
throw err;
}
console.log('JSON Schema created');
});
}
} catch (error) {
console.log(error);
}
})();
开发者ID:pjayala,项目名称:labseed,代码行数:36,代码来源:server.ts
示例5: require
/// <reference path="./express-graphql.d.ts" />
/// <reference path="../express/express.d.ts" />
var express = require("express");
var graphqlHTTP = require("express-graphql");
var app = express();
var schema = {};
app.use("/graphql", graphqlHTTP({ schema: schema, graphiql: true }));
开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:10,代码来源:express-graphql-tests.ts
示例6: require
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from 'graphql';
const pack = require('../package.json');
export const EmptySchema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
description: 'Root query',
fields: {
version: {
type: new GraphQLNonNull(GraphQLString),
resolve: () => pack.version
}
}
})
});
const app = require('express')();
const graphqlHTTP = require('express-graphql');
app.use('/graphql', graphqlHTTP({
schema: EmptySchema,
graphiql: true
}));
app.listen(4000);
开发者ID:2fd,项目名称:graphdoc,代码行数:24,代码来源:empty.ts
注:本文中的express-graphql.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论