Skip to content

Add proper testing harnesses #45

@nirebu

Description

@nirebu

In order to test pieces of application using this abstraction, is not always feasible to stub the methods to return the appropriate records every time. Especially when chaining where, includes and other query methods.

Ideally we need to add some means to intercept the queries, and the hard part is finding the correct place.

Gotchas found in the first quick and dirty attempts:

  • application GraphQL records will have attributes such as email, but the underlying network response has emailAddress.emailAddress
  • where queries are the most difficult: you might query ProductVariants.where(product_id: 123), but the ProductVariant class nor GraphQL type expose a product_id / productId attribute/field to easily filter on the Ruby side

The ideal developer experience would be to define some sort of registry the queries will read the raw data from, so it can pass through the whole pipeline. There's friction: do we want to stub network responses or domain objects? Correct answer would be domain objects, but this makes a translation layer necessary:

stubbed domain objects -> registry format -> loader (test loader?) -> proper objects in application code

This brings more maintenance burden.

ActiveRecord skips all of this writing real records to the database, to mimic this we would need a shadow Shopify GraphQL schema to read from with stubbable data. This would be the most transparent, however feels like a major burden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions