forked from extern/bruno
Merge pull request #807 from vaugenwake/feature/import-graphql-collection
feat: Adding ability to import postman graphql collections
This commit is contained in:
commit
fa8ec4267f
@ -14,6 +14,34 @@ const readFile = (files) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const parseGraphQLRequest = (graphqlSource) => {
|
||||||
|
try {
|
||||||
|
let queryResultObject = {
|
||||||
|
query: '',
|
||||||
|
variables: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof graphqlSource === 'string') {
|
||||||
|
graphqlSource = JSON.parse(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphqlSource.hasOwnProperty('variables') && graphqlSource.variables !== '') {
|
||||||
|
queryResultObject.variables = graphqlSource.variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphqlSource.hasOwnProperty('query') && graphqlSource.query !== '') {
|
||||||
|
queryResultObject.query = graphqlSource.query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryResultObject;
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
|
query: '',
|
||||||
|
variables: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const isItemAFolder = (item) => {
|
const isItemAFolder = (item) => {
|
||||||
return !item.request;
|
return !item.request;
|
||||||
};
|
};
|
||||||
@ -146,6 +174,12 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bodyMode === 'graphql') {
|
||||||
|
brunoRequestItem.type = 'graphql-request';
|
||||||
|
brunoRequestItem.request.body.mode = 'graphql';
|
||||||
|
brunoRequestItem.request.body.graphql = parseGraphQLRequest(i.request.body.graphql);
|
||||||
|
}
|
||||||
|
|
||||||
each(i.request.header, (header) => {
|
each(i.request.header, (header) => {
|
||||||
brunoRequestItem.request.headers.push({
|
brunoRequestItem.request.headers.push({
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
|
Loading…
Reference in New Issue
Block a user