1.1.119 • Published 9 months ago

@satsuma/cli v1.1.119

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

🍊Satsuma CLI

Satsuma's CLI for managing custom graphql queries.

Getting started

This CLI can be run entirely though npx. The get started, head to the folder where your subgraph lives and run:

npx @satsuma/cli init

This will initialize a .satsuma.json, and a folder called custom-queries/ in your project root. The .satsuma.json file stores non-sensitive metadata about your subgraph, and the custom-queries/ folder is where you can configure custom GraphQL.

Writing custom queries

After running init, you'll see that you now have three new files.

typeDefs.ts

This file should export typeDefs, a string containing your custom GraphQL type definitions. This will be merged with your subgraph's schema.

resolvers.ts

This file should export resolvers, an object containing your custom GraphQL resolvers for any added fields in typeDefs.

helpers.ts (optional)

This file should export helpers, an object containing any helper functions you want to use in your resolvers. This will be passed to your resolvers via the graphql context.

Note: You should not import any modules in this file, nor should you import helpers directly into resolvers. It will not work due to the sandbox environment in which your code is executed

Context

All resolvers are passed a context object as the third argument. This context object contains the following properties:

  • db: An object containing knex instances for each of your subgraph's databases.
    • db.entities: The database containing your subgraph's entities.
  • helpers: An object containing any helper functions you've defined in helpers.ts.

Resolvers & Helpers runtime

Resolvers and helpers are run in a node sandbox. This means that we've limited the modules you can use, as well as the limits on the amount of memory and time your code can consume.

  • Max Memory: 1gb
  • Max Runtime: 25 seconds
  • Allowed Modules:
    • lodash (available as _)
    • date-fns (available as dateFns)
    • uuid (available as uuid)
    • moment
    • rxjs
    • ramda (available as R)
    • validator (https://www.npmjs.com/package/validator)
    • console (in local env, this will redirect to your console)

Types

For those who want to work with typescript, you can run the following to generate schema.graphql and schema.ts files.

npx @satsuma/cli codegen -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}

These files will be generated in the custom-queries/ folder. The schema.ts file will contain typescript types that you can import and use in your custom resolvers & helpers.

Note: You should not manually edit types.ts.

Running Locally

When you're ready to test your changes locally, you can run the following command to deploy your custom queries to a local graph node.

npx @satsuma/cli local -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}

This will spin up a server on http://localhost:4000. If you visit that URL, you'll be greeted with Apollo Studio's GraphQL playground.

Deploying

When you're ready to deploy your custom queries to Satsuma, you can run the following command:

npx @satsuma/cli deploy -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}
1.1.119

9 months ago

1.1.118

9 months ago

1.1.117

9 months ago

1.1.116

10 months ago

1.1.115

10 months ago

1.1.29

12 months ago

1.1.28

12 months ago

1.1.100

11 months ago

1.1.30

12 months ago

1.1.108

10 months ago

1.1.34

12 months ago

1.1.107

10 months ago

1.1.33

12 months ago

1.1.106

11 months ago

1.1.32

12 months ago

1.1.105

11 months ago

1.1.31

12 months ago

1.1.104

11 months ago

1.1.38

12 months ago

1.1.103

11 months ago

1.1.37

12 months ago

1.1.102

11 months ago

1.1.36

12 months ago

1.1.101

11 months ago

1.1.35

12 months ago

1.1.39

12 months ago

1.1.41

12 months ago

1.1.40

12 months ago

1.1.45

12 months ago

1.1.44

12 months ago

1.1.43

12 months ago

1.1.42

12 months ago

1.1.49

12 months ago

1.1.48

12 months ago

1.1.47

12 months ago

1.1.46

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.1.9

12 months ago

1.1.8

12 months ago

1.1.7

12 months ago

1.1.6

12 months ago

1.1.5

12 months ago

1.1.4

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.92

11 months ago

1.1.91

11 months ago

1.1.90

11 months ago

1.1.96

11 months ago

1.1.95

11 months ago

1.1.94

11 months ago

1.1.93

11 months ago

1.1.12

12 months ago

1.1.99

11 months ago

1.1.11

12 months ago

1.1.98

11 months ago

1.1.10

12 months ago

1.1.97

11 months ago

1.1.16

12 months ago

1.1.15

12 months ago

1.1.14

12 months ago

1.1.13

12 months ago

1.1.19

12 months ago

1.1.18

12 months ago

1.1.17

12 months ago

1.1.109

10 months ago

1.1.111

10 months ago

1.1.110

10 months ago

1.1.23

12 months ago

1.0.55

12 months ago

1.1.22

12 months ago

1.0.54

12 months ago

1.1.21

12 months ago

1.0.53

12 months ago

1.1.20

12 months ago

1.1.27

12 months ago

1.0.59

12 months ago

1.1.114

10 months ago

1.1.26

12 months ago

1.0.58

12 months ago

1.1.113

10 months ago

1.1.25

12 months ago

1.0.57

12 months ago

1.1.112

10 months ago

1.1.24

12 months ago

1.0.56

12 months ago

1.1.70

12 months ago

1.1.74

12 months ago

1.1.73

12 months ago

1.1.72

12 months ago

1.1.71

12 months ago

1.1.78

11 months ago

1.1.77

11 months ago

1.1.76

12 months ago

1.1.75

12 months ago

1.1.79

11 months ago

1.1.81

11 months ago

1.1.80

11 months ago

1.1.85

11 months ago

1.1.84

11 months ago

1.1.83

11 months ago

1.1.82

11 months ago

1.1.89

11 months ago

1.1.88

11 months ago

1.1.87

11 months ago

1.1.86

11 months ago

1.1.52

12 months ago

1.1.51

12 months ago

1.1.50

12 months ago

1.1.56

12 months ago

1.1.55

12 months ago

1.1.54

12 months ago

1.1.53

12 months ago

1.1.59

12 months ago

1.1.58

12 months ago

1.1.57

12 months ago

1.1.63

12 months ago

1.1.62

12 months ago

1.1.61

12 months ago

1.1.60

12 months ago

1.1.67

12 months ago

1.1.66

12 months ago

1.1.65

12 months ago

1.1.64

12 months ago

1.1.69

12 months ago

1.1.68

12 months ago

1.0.52

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.49

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.14

1 year ago