awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
916 stars 265 forks source link

AWS-AppSync SDK contains AWS-SDK dependency #543

Open indunilasanka opened 4 years ago

indunilasanka commented 4 years ago

AWS-AppSync SDK (javascript: version 3.0.2) contains AWS-SDK dependency ( "aws-sdk": "2.518.0"). Are there any simplified versions. This full sdk is a bit of a heavy for our applications

pechisworks commented 4 years ago

@elorzafe is there any plan to update to aws-sdk version 3 which is tree shakeable?

elorzafe commented 4 years ago

@indunilasanka @pechisworks

Thanks for the feedback, I will talk to other team members to see how can we improve this.

pechisworks commented 3 years ago

@elorzafe can you provide an update?

jaimeburnap commented 3 years ago

Update on this?

CasperAlant commented 3 years ago

Hey, I've started upgrading to aws-sdk v3 and aws-crypto. Please have a look here: https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/master...CasperAlant:upgrade-aws-sdk However, I'm really struggling to make any meaningful progress with the tests.

I tried reimplementing the tests using nock in aws-appsync/tests/link/complex-object-link.test.ts

test('Is run for mutations with a S3Object', done => {
    const scope = nock('https://bucket.s3.region.amazonaws.com')
    .put('/')
    .reply(200)

    const link = complexObjectLink(null);

    const operation = {
        query: gql`mutation { someMutation { aField } }`,
        variables: {
            aFile: {
                bucket: 'bucket',
                key: 'key',
                region: 'region',
                mimeType: 'mimeType',
                localUri: {},
            }
        },
    };

    execute(prepareLinkForTest(link), operation).subscribe({
        next: () => {
          console.log("f")
            expect(scope.isDone()).toBeTruthy();
          console.log("g")
            done();
          console.log("h")
        },
        error: fail
    });
});

but every test that expects a request to be made fails with:

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object
    at Function.from (buffer.js:232:9)
    at writeBody (***/packages/aws-appsync/node_modules/@aws-sdk/node-http-handler/src/write-request-body.ts:25:28)
    at OverriddenClientRequest.httpRequest.on (***/packages/aws-appsync/node_modules/@aws-sdk/node-http-handler/src/write-request-body.ts:10:7)
    at OverriddenClientRequest.emit (events.js:189:13)
    at Immediate.common.setImmediate (***/appsync/packages/aws-appsync/node_modules/nock/lib/intercepted_request_router.js:98:13)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

Any guidance would be appreciated.

trivikr commented 1 month ago

AWS SDK for JavaScript v2 will enter maintenance mode on September 8, 2024 and reach end-of-support on September 8, 2025. For more information, check blog post at https://a.co/cUPnyil

We recommend upgrading to JS SDK v3, especially since it's modular.