How to use the apollo-client/util/observableToPromise function in apollo-client

To help you get started, we’ve selected a few apollo-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github morrys / offline-examples / apollo / todo / client / src / apollo / OfflineFirstApollo.js View on Github external
async function executeMutation(client, link = client.link, offlineRecord) {
    const { request: { payload }, id } = offlineRecord;
    console.log("execute", id, client)
    const operation = payload.operation;
    return observableToPromise({ observable: multiplex(execute(link, operation)) }, result => result);
}
github morrys / wora / packages / apollo-offline / src / ApolloStoreOffline.ts View on Github external
},
    } = offlineRecord;
    const query = client.queryManager.transform(mutation).document;
    const operation = {
        query,
        variables,
        operationName: getOperationName(query) || void 0,
        context: client.queryManager.prepareContext({
            ...context,
            forceFetch: true,
        }),
    };
    const options: Options = {
        observable: multiplex(execute(link, operation)) as any,
    };
    return observableToPromise(options, (result) => result);
}