Skip to content

Commit

Permalink
Remove runtime feature flag
Browse files Browse the repository at this point in the history
Reviewed By: rbalicki2

Differential Revision: D32993543

fbshipit-source-id: 4329f1fb0073666c4f87f51ac754b34bfb528057
  • Loading branch information
captbaritone authored and facebook-github-bot committed Dec 17, 2021
1 parent e8dfee9 commit b0c5a84
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

const {getFragmentResourceForEnvironment} = require('../FragmentResource');
const {
RelayFeatureFlags,
__internal: {fetchQuery},
createOperationDescriptor,
getFragment,
Expand All @@ -22,14 +21,6 @@ const {
} = require('relay-runtime');
const {createMockEnvironment} = require('relay-test-utils');

beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

let environment;
let query;
let FragmentResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const {
FRAGMENT_OWNER_KEY,
FRAGMENTS_KEY,
ID_KEY,
RelayFeatureFlags,
createOperationDescriptor,
getFragment,
getRequest,
Expand Down Expand Up @@ -63,8 +62,6 @@ beforeEach(() => {
jest.mock('warning');
renderSpy = jest.fn();

RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;

// Set up environment and base data
environment = createMockEnvironment();

Expand Down Expand Up @@ -129,7 +126,6 @@ beforeEach(() => {
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
environment.mockClear();
renderSpy.mockClear();
// $FlowFixMe[prop-missing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {createReaderSelector} = require('../../store/RelayModernSelector');
const RelayModernStore = require('../../store/RelayModernStore');
const RelayRecordSource = require('../../store/RelayRecordSource');
const {ROOT_ID} = require('../../store/RelayStoreUtils');
const RelayFeatureFlags = require('../../util/RelayFeatureFlags');
const commitMutation = require('../commitMutation');
const nullthrows = require('nullthrows');
const {createMockEnvironment} = require('relay-test-utils-internal');
Expand Down Expand Up @@ -1099,7 +1098,6 @@ describe('Required mutation roots', () => {
let dataSource;
let environment;
beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
const fetch = jest.fn((_query, _variables, _cacheConfig) => {
return RelayObservable.create(sink => {
dataSource = sink;
Expand Down
8 changes: 0 additions & 8 deletions packages/relay-runtime/query/__tests__/fetchQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

const fetchQuery = require('../fetchQuery');
const {
RelayFeatureFlags,
createOperationDescriptor,
getRequest,
graphql,
Expand Down Expand Up @@ -227,13 +226,6 @@ describe('fetchQuery', () => {
});

describe('fetchQuery with missing @required value', () => {
beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
});
afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

it('provides data snapshot on next', () => {
const requiredFieldLogger = jest.fn();
const environment = createMockEnvironment({
Expand Down
7 changes: 0 additions & 7 deletions packages/relay-runtime/store/RelayReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,6 @@ class RelayReader {
const selection = selections[i];
switch (selection.kind) {
case REQUIRED_FIELD:
invariant(
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES,
'RelayReader(): Encountered a `@required` directive at path "%s" in `%s` without the `ENABLE_REQUIRED_DIRECTIVES` feature flag enabled.',
selection.path,
this._selector.node.name,
);

const fieldValue = this._readRequiredField(selection, record, data);
if (fieldValue == null) {
const {action} = selection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {getSingularSelector} = require('../RelayModernSelector');
const RelayModernStore = require('../RelayModernStore');
const RelayRecordSource = require('../RelayRecordSource');
const nullthrows = require('nullthrows');
const {RelayFeatureFlags} = require('relay-runtime');
const {disallowWarnings} = require('relay-test-utils-internal');

disallowWarnings();
Expand All @@ -45,8 +44,6 @@ describe.each(['RelayModernEnvironment', 'MultiActorEnvironment'])(

describe(environmentType, () => {
beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;

query = getRequest(graphql`
query RelayModernEnvironmentConnectionAndRequiredTestFeedbackQuery(
$id: ID!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {
const {createReaderSelector} = require('../RelayModernSelector');
const RelayModernStore = require('../RelayModernStore');
const RelayRecordSource = require('../RelayRecordSource');
const {RelayFeatureFlags} = require('relay-runtime');
const {disallowWarnings} = require('relay-test-utils-internal');

disallowWarnings();
Expand All @@ -44,8 +43,6 @@ describe('execute() a query with @stream and @required', () => {
let selector;

beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;

query = getRequest(graphql`
query RelayModernEnvironmentExecuteWithStreamAndRequiredTestFeedbackQuery(
$id: ID!
Expand Down Expand Up @@ -94,10 +91,6 @@ describe('execute() a query with @stream and @required', () => {
});
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

it('bubbles @required @stream nodes up to the parent', () => {
const initialSnapshot = environment.lookup(selector);
const callback = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,9 @@ const RelayModernFragmentSpecResolver = require('../RelayModernFragmentSpecResol
const {
createOperationDescriptor,
} = require('../RelayModernOperationDescriptor');
const {
RelayFeatureFlags,
getFragment,
getRequest,
graphql,
} = require('relay-runtime');
const {getFragment, getRequest, graphql} = require('relay-runtime');
const {createMockEnvironment} = require('relay-test-utils-internal');

beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

describe('RelayModernFragmentSpecResolver', () => {
let UserFragment;
let UserQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,13 @@ const RelayModernFragmentSpecResolver = require('../RelayModernFragmentSpecResol
const {
createOperationDescriptor,
} = require('../RelayModernOperationDescriptor');
const {
RelayFeatureFlags,
getFragment,
getRequest,
graphql,
} = require('relay-runtime');
const {getFragment, getRequest, graphql} = require('relay-runtime');
const {createMockEnvironment} = require('relay-test-utils');

const dev = __DEV__;

beforeEach(() => {
global.__DEV__ = dev;
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

describe('RelayModernFragmentSpecResolver', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,7 @@ const {read} = require('../RelayReader');
const RelayRecordSource = require('../RelayRecordSource');
const {RelayFeatureFlags, createReaderSelector} = require('relay-runtime');

beforeEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = true;
});

afterEach(() => {
RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;
});

describe('RelayReader @required', () => {
it('throws if a @required is encounted without the ENABLE_REQUIRED_DIRECTIVES feature flag enabled', () => {
const source = RelayRecordSource.create({
'client:root': {
__id: 'client:root',
__typename: '__Root',
me: {__ref: '1'},
},
'1': {
__id: '1',
id: '1',
__typename: 'User',
firstName: 'Alice',
lastName: null,
},
});
const FooQuery = graphql`
query RelayReaderRequiredFieldsTest1Query {
me {
firstName
lastName @required(action: LOG)
}
}
`;
const operation = createOperationDescriptor(FooQuery, {id: '1'});

RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES = false;

expect(() => {
read(source, operation.fragment);
}).toThrowErrorMatchingInlineSnapshot(
'"RelayReader(): Encountered a `@required` directive at path \\"me.lastName\\" in `RelayReaderRequiredFieldsTest1Query` without the `ENABLE_REQUIRED_DIRECTIVES` feature flag enabled."',
);
});

it('bubbles @required(action: LOG) scalars up to LinkedField', () => {
const source = RelayRecordSource.create({
'client:root': {
Expand Down
2 changes: 0 additions & 2 deletions packages/relay-runtime/util/RelayFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type FeatureFlags = {|
ENABLE_VARIABLE_CONNECTION_KEY: boolean,
ENABLE_PARTIAL_RENDERING_DEFAULT: boolean,
ENABLE_REACT_FLIGHT_COMPONENT_FIELD: boolean,
ENABLE_REQUIRED_DIRECTIVES: boolean | string,
ENABLE_RELAY_RESOLVERS: boolean,
ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: boolean,
ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: boolean,
Expand All @@ -42,7 +41,6 @@ const RelayFeatureFlags: FeatureFlags = {
ENABLE_VARIABLE_CONNECTION_KEY: false,
ENABLE_PARTIAL_RENDERING_DEFAULT: true,
ENABLE_REACT_FLIGHT_COMPONENT_FIELD: false,
ENABLE_REQUIRED_DIRECTIVES: false,
ENABLE_RELAY_RESOLVERS: false,
ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: false,
ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: false,
Expand Down

0 comments on commit b0c5a84

Please sign in to comment.