我正在使用 nextJS,我希望用 apollo 输出我的前端 React 查询,但没有配置起作用。当我使用时,我的查询出现未知错误,import {gql} from src/__generated__/gql当我将鼠标悬停在 gql() 上时,出现以下消息:
The query argument is unknown! Please regenerate the types
我的问题是,因为我使用的是 nextJS,所以我需要做一些不同的事情吗?我希望能够将TypeScript 与 Apollo 客户端代码 gendocs 一起使用,以便输入我的 gql 查询
我的整个 pothos 架构都在我的pages/api/index.ts文件中(我还不知道如何将此代码分散到多个文件中)
查询示例:
const CREATED_EVENT_QUERY = gql(`
query EventById($id: mongoId!) {
eventById(id: $id) {
_id
name
description
location{
coordinates
}
date
eventApplicants{
name
userId
weight
}
link
weights{
weight
spotsAvailable{
name
userId
}
}
}
}
`);
// Apollo Query
const { …Run Code Online (Sandbox Code Playgroud) <html>
<form class="form-disable">
<br>
<input type="text" id="message2">
<br>
<button id="myButton" type="submit" onclick="text()"disabled>Generate Text</button>
</form>
</html>
<script>
// $("html").click(function(event){
// $("#myButton").attr("disabled", "disabled");
// event.preventDefault();
// })
function text(){
let $box = $('#message2').val();
alert($box);
}
$("#message2").click(function(){
$("#myButton").removeAttr("disabled");
// event.preventDefault();
})
</script>
Run Code Online (Sandbox Code Playgroud)
我试过使用带有警报的注释掉功能,它似乎在我点击屏幕上的任何地方时都会出现警报。所以,我担心我的问题是当我单击文本输入字段时,注释掉的函数也会添加禁用属性。当该功能被注释掉时,提交按钮将被禁用,直到我单击输入字段,但是一旦用户单击输入框/字段,我无法弄清楚如何禁用该按钮。
graphql ×1
html ×1
javascript ×1
jquery ×1
next.js ×1
react-apollo ×1
reactjs ×1
typescript ×1