Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"@types/relay-runtime": "^1.3.1",
"immutable": "~3.7.6",
"invariant": "2.2.2",
"relay-compiler": "file:../relay/dist/relay-compiler-1.4.1.tgz",
"relay-runtime": "file:../relay/dist/relay-runtime-1.4.1.tgz",
"relay-compiler": "file:../relay/dist/relay-compiler/relay-compiler-1.4.1-plugin.2.tgz",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you checkout https://github.com/alloy/relay/pull/5 right now and run npm pack in each of the dist subdirs, then this should work.

"yargs": "^9.0.0"
},
"peerDependencies": {
Expand All @@ -29,5 +28,7 @@
"@types/yargs": "10.0.1",
"typescript": "2.6.2"
},
"resolutions": {}
"resolutions": {
"relay-runtime": "file:../relay/dist/relay-runtime/relay-runtime-1.4.1-plugin.2.tgz"
}
}
50 changes: 50 additions & 0 deletions types/relay-compiler/language/RelayLanguagePluginInterface.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { RelayConcreteNode } from 'relay-runtime';
import { Root, Fragment, IRTransform } from '../../graphql-compiler';

export type GraphQLTag = {
keyName: string | null,
template: string,
sourceLocationOffset: {
/* TODO: Is this also expected to use 1-based index? */
line: number,
/* Should use 1-based index */
column: number,
}
};

/**
* Generate a module for the given document name/text.
*/
export type FormatModule = (args: {
moduleName: string,
documentType:
| typeof RelayConcreteNode.FRAGMENT
| typeof RelayConcreteNode.REQUEST
| typeof RelayConcreteNode.BATCH_REQUEST
| null,
docText: string | null,
concreteText: string,
typeText: string,
hash: string | null,
devOnlyAssignments: string | null,
relayRuntimeModule: string,
sourceHash: string,
}) => string;

export type GraphQLTagFinder = (
text: string,
) => Array<GraphQLTag>;

export interface TypeGenerator {
transforms: Array<IRTransform>,
// For now this is an opaque set of options communicated from the bin to the plugin.
generate: (node: Root | Fragment, options: any) => string,
}

export interface PluginInterface {
inputExtensions: string[],
outputExtension: string,
findGraphQLTags: GraphQLTagFinder,
formatModule: FormatModule,
typeGenerator: TypeGenerator,
}
Loading