GraphQL: Renaming Types/Inputs (#5883)
* Renaming GraphQL Types/Inputs * Add Native Type to avoid collision * Use pluralize for renaming * Fixing tests * Improve name collision management - tests passsing * Renaming few more default types * Rename file input * Reverting fields types to not collide with the relay spec types Improver users mutations * Adding ArrayResult to the reserved list * Fixing tests * Add more unit tests to ParseGraphQLSchema * Test transformClassNameToGraphQL * Name collision tests
This commit is contained in:
committed by
Antonio Davi Macedo Coelho de Castro
parent
cf6e79ee75
commit
59b0221fec
21
src/GraphQL/transformers/mutation.js
Normal file
21
src/GraphQL/transformers/mutation.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const parseMap = {
|
||||
_op: '__op',
|
||||
};
|
||||
|
||||
const transformMutationInputToParse = fields => {
|
||||
if (!fields || typeof fields !== 'object') {
|
||||
return;
|
||||
}
|
||||
Object.keys(fields).forEach(fieldName => {
|
||||
const fieldValue = fields[fieldName];
|
||||
if (parseMap[fieldName]) {
|
||||
delete fields[fieldName];
|
||||
fields[parseMap[fieldName]] = fieldValue;
|
||||
}
|
||||
if (typeof fieldValue === 'object') {
|
||||
transformMutationInputToParse(fieldValue);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export { transformMutationInputToParse };
|
||||
Reference in New Issue
Block a user