graphql-x-sketch icon indicating copy to clipboard operation
graphql-x-sketch copied to clipboard

Querying a Sketch file with the flexibility of GraphQL

GraphQL x Sketch

Querying a Sketch file with the flexibility of GraphQL

dziqgfjx4aafxnl jpg-large

Installation

npm install -g graphql-x-sketch

Usage

Server

graphql-x-sketch path/to/your/sketch/file

You can either point to a sketch file directly or to a folder that contains multiple Sketch files. You can also pass multiple paths.

This will spawn a local GraphQL server (and a GraphiQL instance so that you can play with it).

The server will also serve the bitmaps bundled in the Sketch files. The image field of a BitmapLayer will be the URL to the image for example.

The server will also watch the paths for new/updates Sketch files.

Single query

You can also directly run a GraphQL query without spwaning a server:

graphql-x-sketch path/to/your/sketch/file --run="my-graphql-query" --variables="{\"myVariable\": 3}"

That could serve as an alternative to sketchtool for example (and runs on any platform since it doesn't have any dependency to Sketch)

Contributing

The graphQL schemas are in /lib/schema