Created
November 18, 2019 06:49
-
-
Save bcherny/63002d4eb9e0a03b1a72e8d8b0f22e44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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