Skip to content

Commit

Permalink
Updating graphql-config to retrieve configuration for files instead…
Browse files Browse the repository at this point in the history
… of folders.
  • Loading branch information
jnwng committed Apr 15, 2018
1 parent 8bf664e commit 5be23a0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import {
includes,
} from 'lodash';

import {
getGraphQLProjectConfig,
ConfigNotFoundError
} from 'graphql-config'
import { getGraphQLConfig, ConfigNotFoundError } from 'graphql-config';

import * as customRules from './rules';

Expand Down Expand Up @@ -196,11 +193,14 @@ export const rules = {
},
create: context => {
return createRule(context, optionGroup =>
parseOptions({
validators: ['RequiredFields'],
options: { requiredFields: optionGroup.requiredFields },
...optionGroup,
})
parseOptions(
{
validators: ['RequiredFields'],
options: { requiredFields: optionGroup.requiredFields },
...optionGroup,
},
context
)
);
},
},
Expand Down Expand Up @@ -242,7 +242,7 @@ export const rules = {
},
};

function parseOptions(optionGroup) {
function parseOptions(optionGroup, context) {
const {
schemaJson, // Schema via JSON object
schemaJsonFilepath, // Or Schema via absolute filepath
Expand All @@ -263,8 +263,8 @@ function parseOptions(optionGroup) {
schema = initSchemaFromString(schemaString);
} else {
try {
const config = getGraphQLProjectConfig('.', projectName);
schema = config.getSchema()
const config = getGraphQLConfig();
schema = config.getConfigForFile(context.getFilename()).getSchema();
} catch (e) {
if (e instanceof ConfigNotFoundError) {
throw new Error('Must provide .graphqlconfig file or pass in `schemaJson` option ' +
Expand Down

0 comments on commit 5be23a0

Please sign in to comment.