()
| 94 | } |
| 95 | |
| 96 | async load() { |
| 97 | const { parseGraphQLConfig } = await this._initializeSchemaAndConfig(); |
| 98 | const parseClassesArray = await this._getClassesForSchema(parseGraphQLConfig); |
| 99 | const functionNames = await this._getFunctionNames(); |
| 100 | const functionNamesString = functionNames.join(); |
| 101 | |
| 102 | const parseClasses = parseClassesArray.reduce((acc, clazz) => { |
| 103 | acc[clazz.className] = clazz; |
| 104 | return acc; |
| 105 | }, {}); |
| 106 | if ( |
| 107 | !this._hasSchemaInputChanged({ |
| 108 | parseClasses, |
| 109 | parseGraphQLConfig, |
| 110 | functionNamesString, |
| 111 | }) |
| 112 | ) { |
| 113 | return this.graphQLSchema; |
| 114 | } |
| 115 | |
| 116 | this.parseClasses = parseClasses; |
| 117 | this.parseGraphQLConfig = parseGraphQLConfig; |
| 118 | this.functionNames = functionNames; |
| 119 | this.functionNamesString = functionNamesString; |
| 120 | this.parseClassTypes = {}; |
| 121 | this.viewerType = null; |
| 122 | this.cloudConfigType = null; |
| 123 | this.graphQLAutoSchema = null; |
| 124 | this.graphQLSchema = null; |
| 125 | this.graphQLTypes = []; |
| 126 | this.graphQLQueries = {}; |
| 127 | this.graphQLMutations = {}; |
| 128 | this.graphQLSubscriptions = {}; |
| 129 | this.graphQLSchemaDirectivesDefinitions = null; |
| 130 | this.graphQLSchemaDirectives = {}; |
| 131 | this.relayNodeInterface = null; |
| 132 | |
| 133 | defaultGraphQLTypes.load(this); |
| 134 | defaultRelaySchema.load(this); |
| 135 | schemaTypes.load(this); |
| 136 | |
| 137 | this._getParseClassesWithConfig(parseClassesArray, parseGraphQLConfig).forEach( |
| 138 | ([parseClass, parseClassConfig]) => { |
| 139 | // Some times schema return the _auth_data_ field |
| 140 | // it will lead to unstable graphql generation order |
| 141 | if (parseClass.className === '_User') { |
| 142 | Object.keys(parseClass.fields).forEach(fieldName => { |
| 143 | if (fieldName.startsWith('_auth_data_')) { |
| 144 | delete parseClass.fields[fieldName]; |
| 145 | } |
| 146 | }); |
| 147 | } |
| 148 | |
| 149 | // Fields order inside the schema seems to not be consistent across |
| 150 | // restart so we need to ensure an alphabetical order |
| 151 | // also it's better for the playground documentation |
| 152 | const orderedFields = {}; |
| 153 | Object.keys(parseClass.fields) |
no test coverage detected