Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unable to use variable as graphql input #421

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: hooks not cloned in loop
  • Loading branch information
yanghua-ola committed Mar 23, 2023
commit 4081b57a20308b1dab9800962b072f0bf731a02a
2 changes: 1 addition & 1 deletion src/store/httpRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class HttpRegion implements models.HttpRegion {
const httpRegion = new HttpRegion(this.httpFile);
httpRegion.request = this.request;
Object.assign(httpRegion.symbol, this.symbol);
Object.assign(httpRegion.hooks, this.symbol);
Object.assign(httpRegion.hooks, this.hooks);
Object.assign(httpRegion.variablesPerEnv, this.variablesPerEnv);
Object.assign(httpRegion.metaData, this.metaData);
return httpRegion;
Expand Down
43 changes: 43 additions & 0 deletions src/test/request/graphql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,49 @@ query launchesQuery($limit: Int!){
}
}

{{ variables }}
`);

const requests = await mockedEndpoints.getSeenRequests();
expect(requests[0].url).toBe('http://localhost:7002/graphql');
expect(await requests[0].body.getText()).toBe(
'{"query":"query launchesQuery($limit: Int!){\\n launchesPast(limit: $limit) {\\n mission_name\\n launch_date_local\\n launch_site {\\n site_name_long\\n }\\n rocket {\\n rocket_name\\n rocket_type\\n }\\n ships {\\n name\\n home_port\\n image\\n }\\n }\\n}","operationName":"launchesQuery","variables":{"limit":10}}'
);
});

it('query + operation + loop', async () => {
initFileProvider();
const mockedEndpoints = await localServer.forPost('/graphql').thenReply(200);

await sendHttp(`
{{
exports.variables = {
"limit": 10
};
}}

# @loop for 1
POST http://localhost:7002/graphql

query launchesQuery($limit: Int!){
launchesPast(limit: $limit) {
mission_name
launch_date_local
launch_site {
site_name_long
}
rocket {
rocket_name
rocket_type
}
ships {
name
home_port
image
}
}
}

{{ variables }}
`);

Expand Down