Created
August 17, 2017 15:14
-
-
Save lassombra/0ae114acbec9238b06c95dd84239986c to your computer and use it in GitHub Desktop.
resolvers for file example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
Query: { | |
file({id}) { | |
// connector is a dataload aware connector which has been instantiated | |
// with information about this domain specifically | |
return connector.get(id, context); | |
} | |
}, | |
File: { | |
// definite candidate for memoization | |
filePath({filePath}) { | |
return '/' + filePath.split('FileManager\\')[1].replace('\\', '/'); | |
}, | |
// candidate for memoization | |
thumbnailPath({generatedSizes}) { | |
let size = generatedSizes.filter(size => size.imageSize.description == 'Thumbnail')[0]; | |
// Config is an import that has environment specific information | |
return size && (`${Config.current.fileUrlRoot}${size.image.filePath.split(Config.current.fileRoot)[1]}`).replace(/\\/g, '/'); | |
}, | |
// definite candidate for memoization | |
downloadPath({filePath}) { | |
return (`${Config.current.fileUrlRoot}${filePath.split(Config.current.fileRoot)[1]}`).replace(/\\/g, '/'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment