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

indexer-cli: add the --fields option #547

Merged
merged 3 commits into from
Dec 6, 2022
Merged

Conversation

tilacog
Copy link
Contributor

@tilacog tilacog commented Nov 23, 2022

This PR introduces the --fields option to the indexer actions get subcommand.

Filed names passed to this option will be used to select the columns displayed in stdout after the Actions query resolves.

For instance, passing the --fieds id,type,source,transaction will produce the following output.

✔ Processed input parameters
✔ Actions query returned
┌────┬──────────┬──────────────┬────────────────────────────────────────────────────────────────────┐
│ id │ type     │ source       │ transaction                                                        │
├────┼──────────┼──────────────┼────────────────────────────────────────────────────────────────────┤
│ 1  │ allocate │ indexerAgent │ 0x89a4be44e65bde2ef3509f5eeb59e3f33d8fa4b0bb67c015717d41a04051b2a8 │
└────┴──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘

@tilacog tilacog requested a review from fordN November 24, 2022 19:48
@tilacog tilacog marked this pull request as ready for review November 24, 2022 19:48
Copy link
Contributor

@fordN fordN left a comment

Choose a reason for hiding this comment

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

Looks good! If we can remove the need for the hardcoded array of fields that'd be great!

Also, could you add a few actions get ... tests? One for successful use of --fields and at least one for the failure modes? Similar to the rules get tests we already have.

@tilacog
Copy link
Contributor Author

tilacog commented Dec 2, 2022

As of 14b6176, tests fail when interacting with the GraphQL library.

packages/index-cli/src/__tests__/indexer/actions.test.ts:

- Queueing allocate action, target: QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr
✖ [GraphQL] Cannot read properties of undefined (reading 'subgraphDeployment')
- Querying actions
✖ [GraphQL] Cannot read properties of undefined (reading 'fetchActions')

I'm not sure what's the cause of this problem.

This is the query result object, for reference:

{
  operation: {
    key: 2586502677,
    query: { kind: 'Document', definitions: [Array], loc: [Location] },
    variables: { filter: {}, orderBy: 'id', orderDirection: 'desc', first: 10000 },
    kind: 'query',
    context: {
      _instance: undefined,
      url: 'http://localhost:18000/',
      fetchOptions: undefined,
      fetch: [Function (anonymous)],
      preferGetMethod: false,
      suspense: false,
      requestPolicy: 'cache-first',
      meta: [Object]
    }
  },
  data: null,
  error: [CombinedError: [GraphQL] Cannot read properties of undefined (reading 'fetchActions')] {
    graphQLErrors: [ [GraphQLError] ],
    networkError: undefined,
    response: Response {
      size: 0,
      timeout: 0,
      [Symbol(Body internals)]: [Object],
      [Symbol(Response internals)]: [Object]
    }
  },
  extensions: undefined,
  hasNext: false
}

@tilacog tilacog force-pushed the tiago/indexer-cli-field-selector branch 2 times, most recently from 6c3a111 to 8448e4c Compare December 2, 2022 20:36
@tilacog
Copy link
Contributor Author

tilacog commented Dec 2, 2022

Included some tests for --field, --first and a combination of both options.

Copy link
Contributor

@fordN fordN left a comment

Choose a reason for hiding this comment

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

Looks great!
I only have a few message formatting suggestions now. 😄
...and a reminder to rebase or squash commits before rebase&merge, so we're left with a readable, meaningful commit history!

@tilacog tilacog force-pushed the tiago/indexer-cli-field-selector branch from bc4e412 to e9ed321 Compare December 6, 2022 22:21
@tilacog
Copy link
Contributor Author

tilacog commented Dec 6, 2022

Squashed and rebased commits for a more concise history

@tilacog tilacog merged commit 0bc7a72 into main Dec 6, 2022
@tilacog tilacog deleted the tiago/indexer-cli-field-selector branch December 6, 2022 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🚗 Merged
Development

Successfully merging this pull request may close these issues.

2 participants