Exchange is responsible for the various types of e-commerce interactions available on the Artsy platform. It uses Ruby, Rails, Postgresql, and exposes a GraphQL API.
- State: production
- Production: https://exchange.artsy.net, Admin Dashboard | Sidekiq Dashboard
- Staging: https://exchange-staging.artsy.net, Admin Dashboard | Sidekiq Dashboard
- GitHub: https://github.com/artsy/exchange/
- Point People: @sweir27, @ansor4
- CI/Deploys: CircleCi; merged PRs to
artsy/exchange#master
are automatically deployed to staging; PRs fromstaging
torelease
are automatically deployed to production. Start a deploy...
-
Clone the project:
$ git clone [email protected]:artsy/exchange.git
-
Read and/or run the setup script:
cat ./bin/setup ./bin/setup
-
Run Procfile.dev via foreman to start the web (rails) and worker (sidekiq) services:
foreman start -f Procfile.dev
Once setup, you can run the tests like this:
$ bundle exec rspec
Exchange uses shared configuration to distribute common and sensitive configuration values. The setup script will download .env.shared
and also initialize .env
(from .env.example
). The .env
file is for custom configuration and any overrides.
If a new sensitive (or common) environment variable needs to be added for development, remember to also update the shared configuraton in S3. Find update instructions here. This is only required when expanding shared development environment configuration.
We use the PaperTrail gem to maintain a log of data changes to important models within the main relational database.
If you changed something in the /models
make sure to inform #data (analytics) team about it in case it impacts their reports.
Metaphysics is the current consumer of Exchange GraphQL schema and keeps a copy of latest schema in https://github.com/artsy/metaphysics/tree/master/src/data, if you have changed Exchange GraphQL schema, make sure you also update the copy of this schema in Metaphysics. In order to do so follow these steps:
- In exchange run
rake graphql:schema:idl
- rename
schema.graphql
file generated โ๐ผ toexchange.graphql
mv schema.graphql exchange.graphql
- copy file above to your local update Metaphysics under
src/data
and make a PR to Metaphysics with this change.
There is a guide on how to add exchange operations to Metaphysics here
In order to talk to Exchange GraphQL endpoint:
- Run
./bin/setup
. - Start local server
./bin/server
. - If you work at Artsy, get proper Gravity User Token following these instructions (the client application name is "Exchange Staging").
- Install and run GraphiQL app
brew cask install graphiql
. - In GraphiQL app, go to http://localhost:3000/api/graphql, you should ge unauthorized error.
- Edit HTTP Headers and add
Authorization
header and set it toBearer <token>
where<token>
is your Gravity token generated few steps above.
We share our GraphQL sample queries using Insomnia shared workspace. You can import latest queries from environments_and_requests.json
Access to Exchange Admin is limited to users with the role "Sales Admin". Ask someone with Role Manager permissions to grant your user "Sales Admin" permissions.
Something went wrong? Ideally in the JSON response returned from Exchange there will be enough info to describe what went wrong. In case that was not useful, you can:
- Check Sentry (password in 1Pass) and look for Exchange (staging or production) and see the error.
- Follow exchange logs by doing
hokusai staging logs -f
If you think there is something we could improve in this error case, feel free to open an issue with details about what you did and what went wrong.
This repo is closed source in order to avoid leaking potentially sensitive information about partnerships and new features through normal development.