Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 49 additions & 0 deletions client/packages/cli/__tests__/e2e/cli.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,55 @@ export default _schema;
}
});

it('returns singular object for has-one relationships', async () => {
const { appId, adminToken } = await createTempApp();
const project = await createTestProject({
appId,
schemaFile: SCHEMA_FILE,
});

try {
const pushResult = await runCli(['push', 'schema', '--yes'], {
cwd: project.dir,
env: {
INSTANT_CLI_AUTH_TOKEN: adminToken,
INSTANT_APP_ID: appId,
},
});
expect(pushResult.exitCode).toBe(0);

const postId = randomUUID();
const commentId = randomUUID();
await adminTransact(appId, adminToken, [
['update', 'posts', postId, { title: 'My Post', body: 'Content' }],
['update', 'comments', commentId, { text: 'Great post!' }],
['link', 'posts', postId, { comments: commentId }],
]);

// Query from the "has one" side: comments -> post
const result = await runCli(
['query', '--admin', JSON.stringify({ comments: { post: {} } })],
{
cwd: project.dir,
env: {
INSTANT_CLI_AUTH_TOKEN: adminToken,
INSTANT_APP_ID: appId,
},
},
);

expect(result.exitCode).toBe(0);
const data = JSON.parse(result.stdout);
expect(data.comments).toHaveLength(1);

const post = data.comments[0].post;
expect(post).not.toBeInstanceOf(Array);
expect(post.title).toBe('My Post');
} finally {
await project.cleanup();
}
});

it('--as-email runs query as a specific user with perms applied', async () => {
const { appId, adminToken } = await createTempApp();

Expand Down
2 changes: 1 addition & 1 deletion client/packages/cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ async function handleQuery(queryArg, opts) {
const res = await fetchJson({
method: 'POST',
path: '/admin/query',
body: { query },
body: { query, 'inference?': true },
headers,
debugName: 'Query',
errorMessage: 'Failed to run query.',
Expand Down
2 changes: 1 addition & 1 deletion client/packages/version/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// Update the version here and merge your code to main to
// publish a new version of all of the packages to npm.

const version = 'v0.22.165';
const version = 'v0.22.166';

export { version };
Loading