Skip to content

Commit

Permalink
Add support for client schemas
Browse files Browse the repository at this point in the history
Summary:
Makes it possible to have a client schema. Not sure if it should be changed to only allow one schema file or if this is good enough.

Forked kassens changes and made some fixes to get it to work.
Closes #2264

Reviewed By: kassens

Differential Revision: D6770734

Pulled By: jstejada

fbshipit-source-id: 9de8f68dc708b6603475d91ae3cf8d19a163a032
  • Loading branch information
edvinerikson authored and facebook-github-bot committed Feb 7, 2018
1 parent ce503af commit 01dd94e
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions packages/relay-compiler/bin/RelayCompilerBin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
CodegenRunner,
ConsoleReporter,
WatchmanClient,
DotGraphQLParser,
} = require('graphql-compiler');

const RelayJSModuleParser = require('../core/RelayJSModuleParser');
Expand Down Expand Up @@ -130,22 +131,43 @@ Ensure that one such file exists in ${srcDir} or its parents.

const useWatchman = options.watchman && (await WatchmanClient.isAvailable());

const schema = getSchema(schemaPath);
const parserConfigs = {
default: {
js: {
baseDir: srcDir,
getFileFilter: RelayJSModuleParser.getFileFilter,
getParser: RelayJSModuleParser.getParser,
getSchema: () => getSchema(schemaPath),
getSchema: () => schema,
watchmanExpression: useWatchman ? buildWatchExpression(options) : null,
filepaths: useWatchman ? null : getFilepathsFromGlob(srcDir, options),
},
graphql: {
baseDir: srcDir,
getParser: DotGraphQLParser.getParser,
getSchema: () => schema,
watchmanExpression: useWatchman
? buildWatchExpression({
extensions: ['graphql'],
include: options.include,
exclude: options.exclude,
})
: null,
filepaths: useWatchman
? null
: getFilepathsFromGlob(srcDir, {
extensions: ['graphql'],
include: options.include,
exclude: options.exclude,
}),
},
};
const writerConfigs = {
default: {
js: {
getWriter: getRelayFileWriter(srcDir),
isGeneratedFile: (filePath: string) =>
filePath.endsWith('.js') && filePath.includes('__generated__'),
parser: 'default',
parser: 'js',
baseParsers: ['graphql'],
},
};
const codegenRunner = new CodegenRunner({
Expand Down

0 comments on commit 01dd94e

Please sign in to comment.