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

Add playground to sparrowql #41

Merged
merged 6 commits into from
Jan 19, 2024
Merged

Add playground to sparrowql #41

merged 6 commits into from
Jan 19, 2024

Conversation

ErnestTeluk
Copy link
Contributor

Add playground to sparrowql

Comment on lines 1 to 19
export const example2 = `const aliases = {
'owners': 'users',
'employees': 'users'
}

const relations = [
{ from: 'employments', local: 'salonId', to: 'salons', foreign: '_id'},
{ from: 'salons', local: 'businessId', to: 'businesses', foreign: '_id'},
{ from: 'businesses', local: 'ownerId', to: 'owners', foreign: '_id'},
{ from: 'employments', local: 'userId', to: 'employees', foreign: '_id'},
];

const start = 'employments';

const projection = {
salonName: 'salons.name',
employee: 'employees.firstName',
employer: 'owners.firstName'
};`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const example2 = `const aliases = {
'owners': 'users',
'employees': 'users'
}
const relations = [
{ from: 'employments', local: 'salonId', to: 'salons', foreign: '_id'},
{ from: 'salons', local: 'businessId', to: 'businesses', foreign: '_id'},
{ from: 'businesses', local: 'ownerId', to: 'owners', foreign: '_id'},
{ from: 'employments', local: 'userId', to: 'employees', foreign: '_id'},
];
const start = 'employments';
const projection = {
salonName: 'salons.name',
employee: 'employees.firstName',
employer: 'owners.firstName'
};`;
export const example2 = `const aliases = {
'owners': 'users',
'employees': 'users'
}
const relations = [
{ from: 'employments', local: 'restaurantId', to: 'restaurants', foreign: '_id'},
{ from: 'restaurants', local: 'businessId', to: 'businesses', foreign: '_id'},
{ from: 'businesses', local: 'ownerId', to: 'owners', foreign: '_id'},
{ from: 'employments', local: 'userId', to: 'employees', foreign: '_id'},
];
const start = 'employments';
const projection = {
restaurantName: 'restaurants.name',
employee: 'employees.name',
employer: 'owners.name'
};`;

Comment on lines +6 to +15
const fn = `
function get() {
if (typeof aliases !== 'undefined') {
return {projection, relations, start, aliases };
}
return { projection, relations, start };
}

get();
`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add other parameters like limit, offset, and so on.

updateQuery(example1);
}
}, []);
const _setInput = (value: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To distinguish it from the state change, maybe let's change the name to something like onInputChanged, or change the state update to setPlaygroundInputState

const hash = '?' + encoded;
window.location.hash = hash;
} catch (_) {
// It's alright.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put a console error or warning?

Comment on lines 30 to 31
- name: Install dependencies
run: npm i -g npm@8 --no-audit && npm ci --no-audit
run: npm i -g npm@8 --no-audit && npm ci --no-audit && cd playground && npm ci --no-audit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional]
Maybe it's worth splitting it into separate phases?

@zaxovaiko zaxovaiko merged commit b211781 into master Jan 19, 2024
15 checks passed
@zaxovaiko zaxovaiko deleted the sparrow-playground branch January 19, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants