How to use the openneuro-client.files.updateFiles function in openneuro-client

To help you get started, we’ve selected a few openneuro-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 OpenNeuroOrg / openneuro / packages / openneuro-cli / src / upload.js View on Github external
export const uploadTree = (client, datasetId) => tree => {
  return client
    .mutate({
      mutation: files.updateFiles,
      variables: { datasetId, files: tree },
    })
    .catch(err => {
      // Since the error response content type does not match the request
      // we need some special error handling any requests with Upload scalars
      if (
        err.hasOwnProperty('networkError') &&
        err.networkError &&
        err.networkError.hasOwnProperty('result')
      ) {
        for (const message of err.networkError.result.errors) {
          // eslint-disable-next-line no-console
          console.error(inspect(message))
        }
        process.exit(1)
      } else {
github OpenNeuroOrg / openneuro / packages / openneuro-app / src / scripts / uploader / upload-mutation.js View on Github external
export const updateFiles = client => (datasetId, fileList) => {
  const tree = treeFromList(fileList)
  // Upload dataset_description.json first
  tree.files = files.sortFiles(tree.files)
  return client.mutate({
    mutation: files.updateFiles,
    variables: { datasetId, files: tree },
    errorPolicy: 'all',
  })
}
github OpenNeuroOrg / openneuro / packages / openneuro-app / src / scripts / utils / datalad.js View on Github external
updateFiles(datasetId, fileTree, options) {
      let mutation = files.updateFiles

      return new Promise((resolve, reject) => {
        client.mutate({
          mutation: mutation,
          variables: {
            datasetId: bids.decodeId(datasetId),
            files: fileTree
          }
        })
        .then(data => {
          console.log('response from updateFiles:', data)
          resolve(data)
        })
        .catch(err => {
          console.log(err)
          reject(err)