Flutter 如何在flattergraphql调用中发送cookie

Flutter 如何在flattergraphql调用中发送cookie,flutter,cookies,graphql,Flutter,Cookies,Graphql,我正在开发一个Graphql查询API,该API读取域cookie并基于返回的数据,但在使用Flatter应用程序时,我无法发送cookie(这是浏览器中的默认设置)。有没有更简单的方法发送cookies 下面是我从域中读取cookie的代码片段。我认为应该有某种方式在httpLink中设置cookie/选项 final cookieManager = WebviewCookieManager(); final gotCookies = await cookieManager.g

我正在开发一个Graphql查询API,该API读取域cookie并基于返回的数据,但在使用Flatter应用程序时,我无法发送cookie(这是浏览器中的默认设置)。有没有更简单的方法发送cookies

下面是我从域中读取cookie的代码片段。我认为应该有某种方式在httpLink中设置cookie/选项

    final cookieManager = WebviewCookieManager();
    final gotCookies = await cookieManager.getCookies('https://someApp.com');
    
    final HttpLink httpLink = HttpLink(
        uri: 'https://someApp.com/graphql',
        includeExtensions: true
    );
    
    ValueNotifier<GraphQLClient> client = ValueNotifier(
       GraphQLClient(
         cache: InMemoryCache(),
         link: httpLink,
       ),
    );
final cookieManager=WebviewCookieManager();
final gotCookies=等待cookieManager.getCookies('https://someApp.com');
最终HttpLink HttpLink=HttpLink(
uri:'https://someApp.com/graphql',
includeExtensions:true
);
ValueNotifier客户端=ValueNotifier(
GraphQLClient(
缓存:InMemoryCache(),
链接:httpLink,
),
);

找到了此问题的解决方案。我们可以在标题中设置cookie,如下所示,它可以工作

HttpLink httpLink = HttpLink(
        uri: 'https://apps.cloudhealthtech.com/ui-session',
        headers: {'Cookie': 'session_id=ctHB0ZewfasKWBWIUu;'});