system("chcp 437");有啥作用,哪位高手解释下?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了system("chcp 437");有啥作用,哪位高手解释下?相关的知识,希望对你有一定的参考价值。
将活动代码页设置为437(默认是936)936 =GBK(显示中文用的),437代表MS-DOS的默认字符集 参考技术A 就一个方法名传递一个字符型的参数进去~怎么可能知道这个方法有什么用呢?
还要看方法里面执行了什么才能知道的
当我在 ApolloGraphQL 中使用 TypeGraphQL 订阅时出错:UnsupportedProtocolError: Unsupported protocol "ws:&quo
【中文标题】当我在 ApolloGraphQL 中使用 TypeGraphQL 订阅时出错:UnsupportedProtocolError: Unsupported protocol "ws:"【英文标题】:Error when I use subscriptions in ApolloGraphQL with TypeGraphQL: UnsupportedProtocolError: Unsupported protocol "ws:" 【发布时间】:2021-12-13 03:34:59 【问题描述】:我根本不知道发生了什么,有人可以帮助我吗?查询和突变就像一个魅力,但订阅不是。我需要在我的电脑上配置一些东西吗?我从未使用过 WebSocket,谢谢!
【问题讨论】:
同样你找到解决办法了吗? 【参考方案1】:Apollo Server 3 移除了对订阅的内置支持。
从 Apollo Server 3 开始,"batteries-included" apollo-server package
不支持订阅。要启用订阅,您必须先切换到apollo-server-express package
(或任何其他支持订阅的 Apollo Server integration package
)。
import 'dotenv/config';
import cors from 'cors';
import createServer from "http";
import execute, subscribe from "graphql";
import SubscriptionServer from "subscriptions-transport-ws";
import makeExecutableSchema from "@graphql-tools/schema";
import PubSub from 'graphql-subscriptions';
import express from "express";
import ApolloServer from "apollo-server-express";
import resolvers from "./resolvers";
import typeDefs from "./typeDefs";
(async function ()
const app = express();
const pubsub = new PubSub();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded(
extended: true
));
// Routes
app.get('/heathcheck', (req, res) =>
res.status(200).send('heath check OK');
);
//Required logic for integrating with Express
const httpServer = createServer(app);
const schema = makeExecutableSchema(
typeDefs,
resolvers,
);
// Same ApolloServer initialization as before, plus the drain plugin.
const server = new ApolloServer(
typeDefs,
resolvers,
context: ( req, res : any) => ( req, res, pubsub ),
schema,
plugins: [
async serverWillStart()
return
async drainServer()
subscriptionServer.close();
;
],
);
const subscriptionServer = SubscriptionServer.create(
schema, execute, subscribe ,
server: httpServer, path: server.graphqlPath
);
//// More required logic for integrating with Express
await server.start();
server.applyMiddleware(
app,
// By default, apollo-server hosts its GraphQL endpoint at the
// server root. However, *other* Apollo Server packages host it at
// /graphql. Optionally provide this to match apollo-server.
path: '/',
cors: false,
);
const PORT = Number(process.env.app_port) || 3030;
// Modified server startup
httpServer.listen(PORT, () =>
console.log(`Server is now running on http://localhost:$PORT/graphql`)
);
)();
完整项目:https://github.com/sun1211/graphql
【讨论】:
这根本没用,伙计。您刚刚从文档中复制粘贴。 你试过@Oliv吗?这个项目运行没有任何错误?你的 apollo 服务器是哪个版本的?我认为没有人愿意帮助您了解这些信息以上是关于system("chcp 437");有啥作用,哪位高手解释下?的主要内容,如果未能解决你的问题,请参考以下文章