Commit a493169c authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'fix-graphqlid-in-rest-requests-webide' into 'master'

Convert GraphQLID to RestID when fetching project data in WebIDE

See merge request gitlab-org/gitlab!75757
parents 5222c429 4860e459
......@@ -4,6 +4,7 @@ import dismissUserCallout from '~/graphql_shared/mutations/dismiss_user_callout.
import axios from '~/lib/utils/axios_utils';
import { joinPaths, escapeFileUrl } from '~/lib/utils/url_utility';
import ciConfig from '~/pipeline_editor/graphql/queries/ci_config.graphql';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { query, mutate } from './gql';
const fetchApiProjectData = (projectPath) => Api.project(projectPath).then(({ data }) => data);
......@@ -12,7 +13,10 @@ const fetchGqlProjectData = (projectPath) =>
query({
query: getIdeProject,
variables: { projectPath },
}).then(({ data }) => data.project);
}).then(({ data }) => ({
...data.project,
id: getIdFromGraphQLId(data.project.id),
}));
export default {
getFileData(endpoint) {
......
......@@ -219,15 +219,21 @@ describe('IDE services', () => {
describe('getProjectData', () => {
it('combines gql and API requests', () => {
const gqlProjectData = {
id: 'gid://gitlab/Project/1',
userPermissions: {
bogus: true,
},
};
const expectedResponse = {
...projectData,
...gqlProjectData,
id: 1,
};
Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } }));
query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } }));
return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then((response) => {
expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } });
expect(response).toEqual({ data: expectedResponse });
expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID);
expect(query).toHaveBeenCalledWith({
query: getIdeProject,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment