我有一个小型 node.js 应用程序,用作使用 graphql-cli 创建的 graph-api。在 localhost 上一切正常,但是当我尝试在 azure 中将它作为 Web 应用程序运行时,我似乎遇到了路径问题。下面的代码片段正在运行 npm start 的本地主机上工作
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: 'xxx',
secret: 'xxx',
debug: true,
}),
}),
})
定义 .graphql 文件之一的路径:
typeDefs: './src/schema.graphql',
考虑到 index.js 与 schema.graphql 位于同一文件夹中的文件夹结构,我觉得有点奇怪
无论如何,这是在 localhost 上运行的,但是当尝试将其作为 azure web 应用程序运行时,我收到以下错误:
No schema found for path: D:\home\site\wwwroot\src\src\schema.graphql
由于这只是一个脚手架应用程序,我不想更改代码中的路径。我不认为他们错了,因为它在本地主机上工作。我在想我在 azure 上缺少一些配置。
这是我的 web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="src/index.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^src/index.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="src/index.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
我的 iisnode.yml 看起来像这样:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.4.0\node.exe"
我尝试了一堆不同的节点版本,但我目前在我的本地主机上运行 8.4.0
有人有什么想法吗?