deep-foundation / deeplinks

https://discord.gg/deep-foundation
The Unlicense
14 stars 9 forks source link

Error: apolloClient is invalid #291

Closed FreePhoenix888 closed 11 months ago

FreePhoenix888 commented 11 months ago

Error

/home/freephoenix888/Programming/deep/payments-tinkoff-c2b-test/node_modules/@deep-foundation/deeplinks/imports/client.js:307
            throw new Error('apolloClient is invalid');
                  ^

Error: apolloClient is invalid
    at DeepClient (/home/freephoenix888/Programming/deep/payments-tinkoff-c2b-test/node_modules/@deep-foundation/deeplinks/imports/client.js:307:19)
    at main (/home/freephoenix888/Programming/deep/payments-tinkoff-c2b-test/demo/demo.ts:20:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.17.1

Code

  const apolloClient = generateApolloClient({
    path:  '3006-deepfoundation-dev-a31.ws-us107.gitpod.io/gql', // Url here is fake. When I use the actual urk it in browser - it opens, so I have no typo in url
    ssl: true,
  });

  const unloginedDeep = new DeepClient({ apolloClient });
  const guest = await unloginedDeep.guest();
  const guestDeep = new DeepClient({ deep: unloginedDeep, ...guest });
  const admin = await guestDeep.login({
    linkId: await guestDeep.id('deep', 'admin'),
  });
  const deep = new DeepClient({ deep: guestDeep, ...admin });

Description

Error happens on this line:

const deep = new DeepClient({ deep: guestDeep, ...admin });

This code was working before. I have taken it from my cheatsheet: https://github.com/deep-foundation/documentation/wiki/CheatSheet#sample-typescript-application-with-initialized-deepclient

I was always using this code for initializing deep client. What is wrong now?

How to reproduce

Run this test

https://github.com/deep-foundation/deeplinks/blob/6307c8bea984c0674a8380d3935accb0566021f0/tests/client.tsx#L46-L62

by using the following command: npm run test -- --testNamePattern "deep.linkId guest and login"

The test is not passed:

  ● client › deep.linkId guest and login

    assert.strictEqual(received, expected)

    Expected value to strictly be equal to:
      undefined
    Received:
      "unexepted"

    Message:
      expected 'unexepted' to equal undefined

    Difference:

      Comparing two different types of values. Expected undefined but received string.

      55 |     assert.notEqual(adminId, undefined)
      56 |     const admin = await guestDeep.login({ linkId: adminId });
    > 57 |     assert.equal(admin.error, undefined)
         |            ^
      58 |     const deep = new DeepClient({ deep: deepClient, ...admin });
      59 |     assert.notEqual(deep.linkId, undefined);
      60 |     assert.notEqual(deep.linkId, 0);

      at equal (tests/client.tsx:57:12)
      at fulfilled (tests/client.js:10:24)
FreePhoenix888 commented 11 months ago

The issue is not reproducible in fresh deep. Maybe I have broken some permissions someway in my previous deep