Github GraphQL v4 API具有所谓的Schema Previews,您可以在其中使用新的架构功能-但它需要自定义的accept
标头。
我以前使用过Apollo客户端,但是我想使用Formidables urlq 来尝试这个新应用。是否可以通过urql客户端设置客户标头?
更新
我认为这已进入代码库,只是没有记录-https://github.com/FormidableLabs/urql/pull/96/files
Github GraphQL v4 API具有所谓的Schema Previews,您可以在其中使用新的架构功能-但它需要自定义的accept
标头。
我以前使用过Apollo客户端,但是我想使用Formidables urlq 来尝试这个新应用。是否可以通过urql客户端设置客户标头?
更新
我认为这已进入代码库,只是没有记录-https://github.com/FormidableLabs/urql/pull/96/files
仔细查看源代码,以下urql
createClient对我有用:
const client = createClient({
url: 'https://api.github.com/graphql',fetchOptions: {
headers: {
Authorization: `bearer ${GITHUB_TOKEN}`,Accept: 'application/vnd.github.packages-preview+json',},})
,
这是我使用的,它工作正常:
$('select[name="kurir"]').on('change',function(){
let origin = $("input[name=city_origin]").val();
let destination = $("select[name=alamat]").val();
let courier = $("select[name=kurir]").val();
let weight = $("input[name=weight]").val();
if(courier){
jQuery.ajax({
url:"/origin="+origin+"&originType=city&destination="+destination+"&destinationType=city&weight="+weight+"&courier="+courier,type:'GET',dataType:'json',success:function(data){
$('select[name="layanan"]').empty();
$.each(data,function(key,value){
$.each(value.costs,function(key1,value1){
$.each(value1.cost,function(key2,value2){
$('select[name="layanan"]').append('<option value="'+ key +'">' + value1.service + '-' + value1.description + '-' +value2.value+ '</option>');
});
});
});
}
});
} else {
$('select[name="layanan"]').empty();
}
});