-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move compiler to separate package (#91)
* Move nova compiler to separate package * Add compiler package * Change files * Add README.md
- Loading branch information
1 parent
d5b1244
commit 39facf2
Showing
15 changed files
with
230 additions
and
12 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@nova-examples-cb714999-40c2-4455-91bf-f4b901a5d77d.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Add new @nova/graphql-compiler package to examples", | ||
"packageName": "@nova/examples", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@nova-graphql-compiler-c75fa6b8-51b1-43ed-b5c1-3687509de3e8.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Move nova compiler to separate package", | ||
"packageName": "@nova/graphql-compiler", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "major", | ||
"comment": "Move nova compiler to separate package", | ||
"packageName": "@nova/react", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# @nova/graphql-compiler | ||
|
||
This package contains the compiler that used to be available with `@nova/react`. This compiler is just here for backwards compatibility. We recommend using [`duct-tape-compiler`](https://github.com/microsoft/graphitation/tree/main/packages/apollo-react-relay-duct-tape-compiler) or the latest [`relay-compiler`](https://relay.dev/docs/getting-started/installation-and-setup/#set-up-the-compiler) instead. | ||
|
||
## Migration from the embedded compiler inside @nova/react | ||
|
||
If you used the embedded compiler inside `@nova/react` you can now use this package instead. This should be a drop in replacement. Upgrading `@nova/react` to version 2.0.0 will remove the embedded compiler. You can then add this package to your project your scripts should keep working. | ||
|
||
## Installation | ||
|
||
Add `@nova/graphql-compiler` to your project. | ||
|
||
Then inside your package.json add the compiler to your `scripts`: | ||
|
||
```json | ||
{ | ||
"scripts": { | ||
"generate": "nova-graphql-compiler" | ||
} | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@nova/graphql-compiler", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"main": "./src/cli.js", | ||
"scripts": { | ||
"lint": "monorepo-scripts lint", | ||
"test": "monorepo-scripts test", | ||
"just": "monorepo-scripts" | ||
}, | ||
"bin": { | ||
"nova-graphql-compiler": "./src/cli.js" | ||
}, | ||
"dependencies": { | ||
"relay-runtime": "12.0.0", | ||
"graphql": "^15.5.0", | ||
"relay-compiler": "^12.0.0", | ||
"relay-compiler-language-graphitation": "^0.8.2", | ||
"yargs": "^16.2.0" | ||
}, | ||
"devDependencies": { | ||
"monorepo-scripts": "*" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/microsoft/nova-facade.git", | ||
"directory": "packages/nova-graphql-compiler" | ||
}, | ||
"sideEffects": false, | ||
"access": "public", | ||
"exports": { | ||
".": { | ||
"require": "./src/cli.js" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"root": true, | ||
"rules": { | ||
"@typescript-eslint/no-var-requires": ["off"] | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/nova-graphql-compiler/src/__fixtures__/schema.graphql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
type Mutation { | ||
feedbackLike(input: FeedbackLikeInput!): FeedbackLikeMutationResult! | ||
} | ||
type Query { | ||
feedback(id: ID!): Feedback! | ||
} | ||
|
||
type FeedbackLikeMutationResult { | ||
feedback: Feedback! | ||
} | ||
|
||
type Feedback { | ||
id: ID! | ||
message: Message! | ||
doesViewerLike: Boolean! | ||
} | ||
|
||
type Message { | ||
text: String! | ||
} | ||
|
||
input FeedbackLikeInput { | ||
feedbackId: ID! | ||
doesViewerLike: Boolean! | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/nova-graphql-compiler/src/__fixtures__/src/Example.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { graphql } from "@nova/react"; | ||
|
||
graphql` | ||
fragment Example_feedbackFragment on Feedback { | ||
id | ||
message { | ||
text | ||
} | ||
doesViewerLike | ||
} | ||
`; |
18 changes: 18 additions & 0 deletions
18
...a-graphql-compiler/src/__fixtures__/src/__generated__/Example_feedbackFragment.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
packages/nova-graphql-compiler/src/__snapshots__/cli.test.js.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`cli generates files 1`] = ` | ||
"/* tslint:disable */ | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
; | ||
import { FragmentRefs } from "@graphitation/apollo-react-relay-duct-tape"; | ||
export type Example_feedbackFragment = { | ||
readonly id: string; | ||
readonly message: { | ||
readonly text: string; | ||
}; | ||
readonly doesViewerLike: boolean; | ||
readonly " $refType": "Example_feedbackFragment"; | ||
}; | ||
export type Example_feedbackFragment$data = Example_feedbackFragment; | ||
export type Example_feedbackFragment$key = { | ||
readonly " $data"?: Example_feedbackFragment$data | undefined; | ||
readonly " $fragmentRefs": FragmentRefs<"Example_feedbackFragment">; | ||
}; | ||
" | ||
`; |
2 changes: 0 additions & 2 deletions
2
packages/nova-react/src/graphql/cli.js → packages/nova-graphql-compiler/src/cli.js
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { spawnSync } = require("child_process"); | ||
const { readFile, rm } = require("fs/promises"); | ||
const path = require("path/posix"); | ||
|
||
describe("cli", () => { | ||
it("generates files", async () => { | ||
// Remove old generated files if they exist | ||
await rm(path.join(__dirname, "__fixtures__/src/__generated__"), { | ||
recursive: true, | ||
force: true, | ||
}); | ||
|
||
// Run the compiler | ||
spawnSync( | ||
"./src/cli.js", | ||
[ | ||
"--schema", | ||
"./src/__fixtures__/schema.graphql", | ||
"--src", | ||
"./src/__fixtures__/src", | ||
"--watchman", | ||
"false", | ||
], | ||
{ | ||
stdio: "inherit", | ||
}, | ||
); | ||
|
||
// Read the generated files | ||
const generatedFiles = await readFile( | ||
path.join( | ||
__dirname, | ||
"__fixtures__/src/__generated__/Example_feedbackFragment.graphql.ts", | ||
), | ||
"utf8", | ||
); | ||
|
||
expect(generatedFiles).toMatchSnapshot(); | ||
}); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3332,9 +3332,9 @@ | |
"@types/react" "^17" | ||
|
||
"@types/react@>=16": | ||
version "18.0.28" | ||
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.28.tgz#accaeb8b86f4908057ad629a26635fe641480065" | ||
integrity sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew== | ||
version "18.2.47" | ||
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.47.tgz#85074b27ab563df01fbc3f68dc64bf7050b0af40" | ||
integrity sha512-xquNkkOirwyCgoClNk85BjP+aqnIS+ckAJ8i37gAbDs14jfW/J23f2GItAf33oiUPQnqNMALiFeoM9Y5mbjpVQ== | ||
dependencies: | ||
"@types/prop-types" "*" | ||
"@types/scheduler" "*" | ||
|
@@ -9313,6 +9313,29 @@ relay-compiler@^10.1.3: | |
signedsource "^1.0.0" | ||
yargs "^15.3.1" | ||
|
||
relay-compiler@^12.0.0: | ||
version "12.0.0" | ||
resolved "https://registry.yarnpkg.com/relay-compiler/-/relay-compiler-12.0.0.tgz#9f292d483fb871976018704138423a96c8a45439" | ||
integrity sha512-SWqeSQZ+AMU/Cr7iZsHi1e78Z7oh00I5SvR092iCJq79aupqJ6Ds+I1Pz/Vzo5uY5PY0jvC4rBJXzlIN5g9boQ== | ||
dependencies: | ||
"@babel/core" "^7.14.0" | ||
"@babel/generator" "^7.14.0" | ||
"@babel/parser" "^7.14.0" | ||
"@babel/runtime" "^7.0.0" | ||
"@babel/traverse" "^7.14.0" | ||
"@babel/types" "^7.0.0" | ||
babel-preset-fbjs "^3.4.0" | ||
chalk "^4.0.0" | ||
fb-watchman "^2.0.0" | ||
fbjs "^3.0.0" | ||
glob "^7.1.1" | ||
immutable "~3.7.6" | ||
invariant "^2.2.4" | ||
nullthrows "^1.1.1" | ||
relay-runtime "12.0.0" | ||
signedsource "^1.0.0" | ||
yargs "^15.3.1" | ||
|
||
[email protected]: | ||
version "10.1.3" | ||
resolved "https://registry.yarnpkg.com/relay-runtime/-/relay-runtime-10.1.3.tgz#1d7bfe590b50cd7f18f6d1c0f20df71fe5bb451a" | ||
|