-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
playground/src/examples/example2.ts
Outdated
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' | ||
};`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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' | |
};`; |
const fn = ` | ||
function get() { | ||
if (typeof aliases !== 'undefined') { | ||
return {projection, relations, start, aliases }; | ||
} | ||
return { projection, relations, start }; | ||
} | ||
|
||
get(); | ||
`; |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
.github/workflows/CI.yml
Outdated
- 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 |
There was a problem hiding this comment.
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?
Add playground to sparrowql