| 25 | } |
| 26 | |
| 27 | export const extractKeysAndInclude = selectedFields => { |
| 28 | selectedFields = selectedFields.filter(field => !field.includes('__typename')); |
| 29 | // Handles "id" field for both current and included objects |
| 30 | selectedFields = selectedFields.map(field => { |
| 31 | if (field === 'id') { return 'objectId'; } |
| 32 | return field.endsWith('.id') |
| 33 | ? `${field.substring(0, field.lastIndexOf('.id'))}.objectId` |
| 34 | : field; |
| 35 | }); |
| 36 | let keys = undefined; |
| 37 | let include = undefined; |
| 38 | |
| 39 | if (selectedFields.length > 0) { |
| 40 | keys = [...new Set(selectedFields)].join(','); |
| 41 | // We can use this shortcut since optimization is handled |
| 42 | // later on RestQuery, avoid overhead here. |
| 43 | include = keys; |
| 44 | } |
| 45 | |
| 46 | return { |
| 47 | // If authData is detected keys will not work properly |
| 48 | // since authData has a special storage behavior |
| 49 | // so we need to skip keys currently |
| 50 | keys: keys && keys.indexOf('authData') === -1 ? keys : undefined, |
| 51 | include, |
| 52 | }; |
| 53 | }; |
| 54 | |
| 55 | export const getParseClassMutationConfig = function (parseClassConfig) { |
| 56 | return (parseClassConfig && parseClassConfig.mutation) || {}; |