Skip to content

Added block as a query option #557

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

Merged

Conversation

lpetkov-sw
Copy link

No description provided.

Copy link
Contributor

@orenyodfat orenyodfat left a comment

Choose a reason for hiding this comment

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

tests are missing

if (typeof options.block === 'object') {
const blockOptionJson = JSON.stringify(options.block)
// Remove quotes from json properties
const unquotedJson = blockOptionJson.replace(/"([^"]+)":/g, '$1:')
Copy link
Contributor

@orenyodfat orenyodfat Oct 28, 2020

Choose a reason for hiding this comment

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

why this option.block is handle differently from other options ? remove quotes ?
whats make it unique ? @lpetkov-sw

Copy link
Author

Choose a reason for hiding this comment

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

The block property in thegraph basically is represented as an object with two possible props - number and hash. ( https://thegraph.com/docs/graphql-api#time-travel-queries )
It's more like the where property then the other 4 props in the options that you have in the createGraphQlQuery method (first, skip, orderBy, orderDirection). They are accepting string as a value. My approach for constructing the block prop is to convert the js object to a JSON, which actually is pretty the same as the thegraph query syntax. The only difference is that the prop shouldn't be a a quoted. So that's why I'm removing the quotes.

@orenyodfat orenyodfat merged commit df0eac1 into daostack:master-2 Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants