Git Product home page Git Product logo

metaphysics's Introduction

Metaphysics

Metaphysics is a GraphQL-compliant API that wraps various Artsy APIs. You can try it here against our staging API.

It is built on express, express-graphql, and graphql. With graphiql providing a sandbox to work with.

It is currently used in production all over the place in Artsy.net, and the Artsy iOS App

Meta CircleCI codecov

Getting Setup

To get yourself set up with all the project's dependencies:

git clone https://github.com/artsy/metaphysics
cd metaphysics

# Run the setup script
./scripts/setup.sh

This will pull the environment variables from aws into .env.shared. It will also overwrite .env with the values in .env.example. If you need to override any of these values or add new .env values place them in the .env file.

Development

With your dependencies set up, you can run Metaphysics by running:

yarn start

Which will start the server on http://localhost:3000

Be sure that memcached is no longer running before starting hokusai by running

brew services stop memcached

Recommended: You can run the commands inside the terminal in VS Code, then the debugger will be hooked up by default.

Setting up your local GraphiQL

We recommend the graphiql.app client for testing queries locally.

You will need to set up headers with both:

  • x-access-token - Open https://staging.artsy.net, sign in and evaluate sd.CURRENT_USER.accessToken in a dev console (CMD+Shift+C in Chrome).
  • x-user-id - As above, but sd.CURRENT_USER.id.

If you're new to GraphQL, you can checkout Artsy's GraphQL Workshop.

For GraphQL Endpoint, set it to http://localhost:3000/v2.

Note that /v2 is the default and /v1 has been fully deprecated and removed.

Introspection Setup

Getting docs for the schema on MP in your playground of choice (Postman, Insomnia, Altair, etc) is called introspection.

Introspection is available by default when developing.

Introspection on staging and production are for internal use only, so artsy devs can use it to make development for MP clients (eigen, force, etc) easier, but it is and should not be used by any of the clients or anyone else.

In order to set this up in your playground of choice (Postman, Insomnia, Altair, etc), you need to send the following header:

Authorization: Bearer <secret>

and replace <secret> with the value you get from hokusai using

hokusai staging env get INTROSPECT_TOKEN
hokusai production env get INTROSPECT_TOKEN

or the contents of Metaphysics INTROSPECT_TOKEN in 1Password.

Sample Queries

Once you have the GraphiQL client running against your local service, you can verify things are working by executing these queries:

Get your account information

{
  me {
    name
    email
  }
}

If any of these queries fail, it's probable that you misconfigured your x-access-token or x-user-id HTTP headers.

Docs

Docker and Kubernetes setup

This is deployed using Hokusai to manage Docker and Kubernetes. To replicate this:

  • Install Docker for Mac and Hokusai

    $ brew tap caskroom/cask && brew cask install docker
    $ pip install hokusai

    If you are using your system Python distribution, you may need to run this as:

    $ sudo pip install hokusai --ignore-installed
  • Configure Hokusai

    export AWS_ACCESS_KEY_ID={{ MY_AWS_ACCESS_KEY_ID }}
    export AWS_SECRET_ACCESS_KEY={{ MY_AWS_SECRET_ACCESS_KEY }}
    hokusai configure --kubectl-version {{ kubectl_version }} --s3-bucket {{ kubectl_config_s3_bucket }} --s3-key {{ kubectl_config_s3_key }}
    hokusai check

    Artsy staff should find follow the instructions in https://github.com/artsy/potential/blob/main/platform/Kubernetes.md#hokusai

  • Start the server

    hokusai dev start

Testing

  • Run tests in the Docker Compose test stack via Hokusai:

    hokusai test
  • Or, to run tests locally: npm test to run the entire suite npm run watch to spin up the test watcher

About Artsy

This project is the work of engineers at Artsy, the world's leading and largest online art marketplace and platform for discovering art. One of our core Engineering Principles is being Open Source by Default which means we strive to share as many details of our work as possible.

You can learn more about this work from our blog and by following @ArtsyOpenSource or explore our public data by checking out our API. If you're interested in a career at Artsy, read through our job postings!

metaphysics's People

Contributors

mzikherman avatar artsy-peril[bot] avatar dzucconi avatar alloy avatar artsyit avatar orta avatar damassi avatar zephraph avatar broskoski avatar sweir27 avatar ashkan18 avatar jonallured avatar izakp avatar anandaroop avatar olerichter00 avatar joeyaghion avatar dblandin avatar ashfurrow avatar sepans avatar renovate-bot avatar peril-staging[bot] avatar kierangillen avatar starsirius avatar mbilokonsky avatar mounirdhahri avatar craigspaeth avatar mdole avatar ds300 avatar eessex avatar oxaudo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.