Skip to content

Commit

Permalink
add back supportServiceless param
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry committed Apr 29, 2024
1 parent f3ba5e0 commit d2b9e86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pages/TermsOfService/hooks/useTermsOfService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function useSaveTermsAgreement(options: SaveTermsAgreementOptions = {}) {
mutationPath: 'saveTermsAgreement',
query: querySignAgreement,
variables,
supportsServiceless: true,
})
},
onSuccess: (data) => {
Expand Down
10 changes: 8 additions & 2 deletions src/shared/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ function prefillMethod(method) {
})
}

function graphql({ provider, query, variables = {}, signal }) {
function graphql({
provider,
query,
variables = {},
signal,
supportsServiceless = false,
}) {
let uri = `${config.API_URL}/graphql/`

if (provider && isProvider(provider)) {
if (provider && isProvider(provider) && !supportsServiceless) {
uri = `${config.API_URL}/graphql/${provider}`
}

Expand Down
18 changes: 18 additions & 0 deletions src/shared/api/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,24 @@ describe('when using a graphql mutation', () => {
})
})

describe('when the mutation supports serviceless', () => {
beforeAll(() => {
result = Api.graphqlMutation({
query: 'query MyInfo { me }',
mutationPath: 'me',
supportsServiceless: true,
})
})

it('resolves with the data', async () => {
return expect(result).resolves.toEqual({
data: {
me: 'Codecov',
},
})
})
})

describe('when graphql query returns a 401 error', () => {
config.IS_SELF_HOSTED = true

Expand Down

0 comments on commit d2b9e86

Please sign in to comment.