Skip to content

Instantly share code, notes, and snippets.

@bcherny
Created November 18, 2019 06:49
Show Gist options
  • Save bcherny/63002d4eb9e0a03b1a72e8d8b0f22e44 to your computer and use it in GitHub Desktop.
Save bcherny/63002d4eb9e0a03b1a72e8d8b0f22e44 to your computer and use it in GitHub Desktop.
import * as t from '@babel/types'
const rawQuery = astql`
node {
...on Function {
__typename
}
}
`;
const query = compile(rawQuery)
const result = run(query)
if (result instanceof Error) {
} else {
}
////// or
query(node) // validate & compile
.match(result =>) // evaluate
.catch(error =>) // validation & compilation errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment