How to use @bbp/nexus-link - 8 common examples

To help you get started, we’ve selected a few @bbp/nexus-link 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 BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }
  // check abort controller presence
  if (!getAbortControllerInstance()) {
    throw new Error(
      'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }

  const defaultLinks = [triggerFetch(fetchInstance)];
  options.token && defaultLinks.unshift(setToken(options.token));
  const links = options.links
    ? [...options.links, ...defaultLinks]
    : defaultLinks;
  const requestHandler = pipe(links);
  const defaultContext = { uri: options.uri };
  const context: NexusContext = options.context
    ? { ...options.context, ...defaultContext }
    : defaultContext;

  const fetchers: Fetchers = {
    httpGet: operation => toPromise(requestHandler(operation)),
    httpPost: operation =>
      toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
    httpPut: operation =>
      toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
    httpPatch: operation =>
      toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
    httpDelete: operation =>
      toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
    poll: pipe([poll(1000), requestHandler]),
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
// get fetch instance
  const fetchInstance = options.fetch || getFetchInstance();
  if (!fetchInstance) {
    throw new Error(
      'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }
  // check abort controller presence
  if (!getAbortControllerInstance()) {
    throw new Error(
      'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }

  const defaultLinks = [triggerFetch(fetchInstance)];
  options.token && defaultLinks.unshift(setToken(options.token));
  const links = options.links
    ? [...options.links, ...defaultLinks]
    : defaultLinks;
  const requestHandler = pipe(links);
  const defaultContext = { uri: options.uri };
  const context: NexusContext = options.context
    ? { ...options.context, ...defaultContext }
    : defaultContext;

  const fetchers: Fetchers = {
    httpGet: operation => toPromise(requestHandler(operation)),
    httpPost: operation =>
      toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
    httpPut: operation =>
      toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
    httpPatch: operation =>
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
export function createNexusClient(options: NexusClientOptions) {
  // get fetch instance
  const fetchInstance = options.fetch || getFetchInstance();
  if (!fetchInstance) {
    throw new Error(
      'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }
  // check abort controller presence
  if (!getAbortControllerInstance()) {
    throw new Error(
      'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
    );
  }

  const defaultLinks = [triggerFetch(fetchInstance)];
  options.token && defaultLinks.unshift(setToken(options.token));
  const links = options.links
    ? [...options.links, ...defaultLinks]
    : defaultLinks;
  const requestHandler = pipe(links);
  const defaultContext = { uri: options.uri };
  const context: NexusContext = options.context
    ? { ...options.context, ...defaultContext }
    : defaultContext;

  const fetchers: Fetchers = {
    httpGet: operation => toPromise(requestHandler(operation)),
    httpPost: operation =>
      toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
    httpPut: operation =>
      toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
httpPost: operation =>
      toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
    httpPut: operation =>
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
httpDelete: operation =>
      toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
    poll: pipe([poll(1000), requestHandler]),
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
httpPut: operation =>
      toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
    httpPatch: operation =>
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
httpPatch: operation =>
      toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
    httpDelete: operation =>
github BlueBrain / nexus-js / packages / nexus-sdk / src / nexusSdk.ts View on Github external
const defaultContext = { uri: options.uri };
  const context: NexusContext = options.context
    ? { ...options.context, ...defaultContext }
    : defaultContext;

  const fetchers: Fetchers = {
    httpGet: operation => toPromise(requestHandler(operation)),
    httpPost: operation =>
      toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
    httpPut: operation =>
      toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
    httpPatch: operation =>
      toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
    httpDelete: operation =>
      toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
    poll: pipe([poll(1000), requestHandler]),
  };

  return {
    context,
    Organization: Organization(fetchers, context),
    Project: Project(fetchers, context),
    Resource: Resource(fetchers, context),
    View: View(fetchers, context),
    Resolver: Resolver(fetchers, context),
    Schema: Schema(fetchers, context),
    File: NexusFile(fetchers, context),
    Storage: Storage(fetchers, context),
    Identity: Identity(fetchers, context),
    Realm: Realm(fetchers, context),
    Permissions: Permissions(fetchers, context),
    ACL: ACL(fetchers, context),

@bbp/nexus-link

A powerful, extendable way of controlling requests/responses to/from Nexus. Inspired by Apollo-link.

Apache-2.0
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis