-
-
Notifications
You must be signed in to change notification settings - Fork 310
/
gql-schema.ts
34 lines (29 loc) · 968 Bytes
/
gql-schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Action } from '@ngrx/store';
import * as gqlSchema from '../../actions/gql-schema/gql-schema';
export interface Variable {
key: string;
value: string;
}
export interface State {
introspection: object;
schema: object;
allowIntrospection: boolean;
}
const initialState: State = {
introspection: null,
schema: null,
allowIntrospection: true
};
export function gqlSchemaReducer(state = initialState, action: gqlSchema.Action): State {
switch (action.type) {
case gqlSchema.SET_INTROSPECTION:
case gqlSchema.SET_INTROSPECTION_FROM_DB:
return Object.assign({}, state, { introspection: action.payload });
case gqlSchema.SET_SCHEMA:
return Object.assign({}, state, { schema: action.payload });
case gqlSchema.SET_ALLOW_INTROSPECTION:
return Object.assign({}, state, { allowIntrospection: action.payload });
default:
return state;
}
}