我已经学习了多个有关角度Web的AppSync教程,但是尝试在NativeScript中重复该过程更加困难。看起来像people have done it before,所以任何使它起作用的人的输入都会很棒。

按照我对常规角度应用程序所做的相同常规过程,我尝试使用aws-appsync和nativescript-nodeify使其与nativescript兼容。添加nativescript-nodeify摆脱了我的最初错误,但是现在我遇到了一个新错误:

我得到的错误是:

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x100b9373c NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2   0x100bc4068 -[TNSRuntime executeModule:referredBy:]
3   0x10056229c
4   0x184fcdfc0 <redacted>
JavaScript stack trace:
1   moduleDeclarationInstantiation@file:///app/tns_modules/aws-appsync/lib/link/non-terminating-link.js:71:26
2   link@[native code]
3   @[native code]
4   promiseReactionJob@[native code]
5   require@[native code]
6   anonymous@file:///app/tns_modules/aws-appsync/lib/link/non-terminating-link.js:71:26
7   evaluate@[native code]
8   moduleEvaluation@[native code]
9   @[native code]
10  promiseReactionJob@[native code]
11  require@[native code]
12  anonymous@file:///app/tns_modules/aws-appsync/lib/link/non-terminating-http-link.js:25:37
13  evaluate@[native code]
14  moduleEvaluation@[native code]
15  @[native code]
16  promiseReactionJob@[native code]
17  require@[native code]
18  anonymous@file:///app/tns_modules/aws-appsync/lib/link/index.js:21:42
19  evaluate@[native code]
20  moduleEvaluation@[native code]
21  @[native code]
22  promiseReactionJob@[native code]
23  require@[native code]
24  anonymous@file:///app/tns_modules/aws-appsync/lib/client.js:87:21
25  evaluate@[native code]
26  moduleEval<\M-b\M^@\M-&>
JavaScript error:
file:///app/tns_modules/aws-appsync/lib/link/non-terminating-link.js:71:26: JS ERROR SyntaxError: Importing binding name 'print' is not found.


初始化AWSAppSyncConfig时出现错误。相关代码如下:

require('nativescript-nodeify');

const appSyncConfig = ...

import AWSAppSyncClient from 'aws-appsync';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';

...

const client = new AWSAppSyncClient({
   url: appSyncConfig.aws_appsync_graphqlEndpoint,
   region: appSyncConfig.aws_appsync_region,
   auth: {
      type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
         jwtToken: ACCESS_TOKEN
      }
});


错误消息指向non-terminated-link.js中的这一行:

var linkUtils_1 = require("apollo-link/lib/linkUtils");

最佳答案

该问题最终与打字稿2.9。*和aws-appsync 1.3.4之间的兼容性问题有关。我将打字稿更新为3.0.3,现在可以使用了

关于amazon-web-services - NativeScript AWS AppSync集成,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52451003/

10-11 08:01