Skip to content

Commit 7fe6924

Browse files
committed
asas
1 parent 3c1c382 commit 7fe6924

File tree

4 files changed

+239
-13
lines changed

4 files changed

+239
-13
lines changed

demo/IntrospectionModal.tsx

Lines changed: 230 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,222 @@ const tabNames = [Presets, SDL, Introspection];
2626
const initialConfig = {
2727
inputType: Presets,
2828
activePreset: defaultPresetName,
29-
sdlText: null,
29+
sdlText: `
30+
interface IFoo {
31+
name: String
32+
}
33+
type Foo implements IFoo {
34+
name: String
35+
}
36+
type Bar {
37+
name: String
38+
}
39+
union FooAndBar = Foo | Bar
40+
41+
# same types
42+
interface I0 {
43+
name: Foo
44+
}
45+
type Example0_hide implements I0 {
46+
name: Foo
47+
}
48+
49+
# possible type of interface
50+
interface I1 {
51+
name: IFoo
52+
}
53+
type Example11_hide implements I1 {
54+
name: IFoo
55+
}
56+
type Example12 implements I1 {
57+
name: Foo
58+
}
59+
60+
# possible type of union
61+
interface I2 {
62+
name: FooAndBar
63+
}
64+
type Example21_hide implements I2 {
65+
name: FooAndBar
66+
}
67+
type Example22 implements I2 {
68+
name: Foo
69+
}
70+
type Example23 implements I2 {
71+
name: Bar
72+
}
73+
74+
# list subtyping
75+
interface I3 {
76+
name: [IFoo]
77+
}
78+
type Example31_hide implements I3 {
79+
name: [IFoo]
80+
}
81+
type Example32 implements I3 {
82+
name: [Foo]
83+
}
84+
85+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86+
# stricker nullability
87+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
88+
89+
# same types
90+
interface I4 {
91+
name: Foo
92+
}
93+
type Example4 implements I4 {
94+
name: Foo!
95+
}
96+
97+
# possible type of interface
98+
interface I5 {
99+
name: IFoo
100+
}
101+
type Example51 implements I5 {
102+
name: IFoo!
103+
}
104+
type Example52 implements I5 {
105+
name: Foo!
106+
}
107+
108+
# same union
109+
interface I6 {
110+
name: FooAndBar
111+
}
112+
type Example6 implements I6 {
113+
name: FooAndBar!
114+
}
115+
116+
# possible type of union
117+
interface I7 {
118+
name: FooAndBar
119+
}
120+
type Example71 implements I7 {
121+
name: Foo!
122+
}
123+
type Example72 implements I7 {
124+
name: Bar!
125+
}
126+
127+
# list subtyping
128+
interface I8 {
129+
name: [IFoo]
130+
}
131+
type Example81 implements I8 {
132+
name: [IFoo!]
133+
}
134+
type Example82 implements I8 {
135+
name: [Foo!]
136+
}
137+
type Example83 implements I8 {
138+
name: [IFoo]!
139+
}
140+
type Example84 implements I8 {
141+
name: [Foo]!
142+
}
143+
type Example85 implements I8 {
144+
name: [IFoo!]!
145+
}
146+
type Example86 implements I8 {
147+
name: [Foo!]!
148+
}
149+
150+
# list subtyping 2
151+
interface I9 {
152+
name: [IFoo!]
153+
}
154+
type Example91_hide implements I9 {
155+
name: [IFoo!]
156+
}
157+
type Example92 implements I9 {
158+
name: [Foo!]
159+
}
160+
type Example93 implements I9 {
161+
name: [IFoo!]!
162+
}
163+
type Example94 implements I9 {
164+
name: [Foo!]!
165+
}
166+
167+
# list subtyping 3
168+
interface I10 {
169+
name: [IFoo]!
170+
}
171+
type Example101_hide implements I10 {
172+
name: [IFoo]!
173+
}
174+
type Example102 implements I10 {
175+
name: [Foo]!
176+
}
177+
type Example103 implements I10 {
178+
name: [IFoo!]!
179+
}
180+
type Example104 implements I10 {
181+
name: [Foo!]!
182+
}
183+
184+
# argument list
185+
interface I11 {
186+
name(some: String): Foo
187+
}
188+
type Example111_hide implements I11 {
189+
name(some: String): Foo
190+
}
191+
type Example112 implements I11 {
192+
name(some: String, aditionalArg:String): Foo
193+
}
194+
195+
196+
197+
198+
union Result =
199+
Example0_hide
200+
| Example11_hide
201+
| Example12
202+
| Example21_hide
203+
| Example22
204+
| Example23
205+
| Example31_hide
206+
| Example32
207+
| Example4
208+
| Example51
209+
| Example52
210+
| Example6
211+
| Example71
212+
| Example72
213+
| Example81
214+
| Example82
215+
| Example83
216+
| Example84
217+
| Example85
218+
| Example86
219+
| Example91_hide
220+
| Example92
221+
| Example93
222+
| Example94
223+
| Example101_hide
224+
| Example102
225+
| Example103
226+
| Example104
227+
| Example111_hide
228+
| Example112
229+
230+
type Query {
231+
getFoo: Result
232+
getFooBar: FooAndBar
233+
# Get one todo item
234+
}
235+
236+
type Mutation {
237+
addTodo(name: String!): String!
238+
}
239+
240+
schema {
241+
query: Query
242+
mutation: Mutation
243+
}
244+
`,
30245
jsonText: null,
31246
};
32247

@@ -60,7 +275,7 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
60275
}
61276

62277
handleCancel = () => {
63-
this.setState({ current: { ...this.state.submitted } })
278+
this.setState({ current: { ...this.state.submitted } });
64279
this.props.onClose();
65280
};
66281

@@ -79,25 +294,25 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
79294
break;
80295
}
81296

82-
this.setState({ submitted: { ...this.state.current } })
297+
this.setState({ submitted: { ...this.state.current } });
83298
this.props.onClose();
84299
};
85300

86-
handlePresetChange = (activePreset) => {
301+
handlePresetChange = activePreset => {
87302
this.changeCurrent({ activePreset });
88-
}
303+
};
89304

90-
handleSDLChange = (event) => {
305+
handleSDLChange = event => {
91306
let sdlText = event.target.value;
92307
if (sdlText === '') sdlText = null;
93308
this.changeCurrent({ sdlText });
94-
}
309+
};
95310

96-
handleJSONChange = (event) => {
311+
handleJSONChange = event => {
97312
let jsonText = event.target.value;
98313
if (jsonText === '') jsonText = null;
99314
this.changeCurrent({ jsonText });
100-
}
315+
};
101316

102317
public render() {
103318
const { open } = this.props;
@@ -126,7 +341,12 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
126341
<Button variant="contained" onClick={this.handleCancel}>
127342
Cancel
128343
</Button>
129-
<Button variant="contained" color="primary" style={{color: 'white'}} onClick={this.handleSubmit}>
344+
<Button
345+
variant="contained"
346+
color="primary"
347+
style={{ color: 'white' }}
348+
onClick={this.handleSubmit}
349+
>
130350
Display
131351
</Button>
132352
</div>

src/graph/dot.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ export function getDot(typeGraph, displayOptions): string {
8181
`;
8282
}
8383

84-
function canDisplayRow(type) {
84+
function canDisplayRow(field) {
85+
//console.log('canDisplayRow', field);
86+
const type = field.type;
87+
if (field.isHidden) {
88+
return !displayOptions.skipInterfaceFields;
89+
}
8590
if (type.kind === 'SCALAR' || type.kind === 'ENUM') {
8691
return displayOptions.showLeafFields;
8792
}
@@ -92,7 +97,7 @@ export function getDot(typeGraph, displayOptions): string {
9297
const relayIcon = field.relayType ? TEXT('{R}') : '';
9398
const deprecatedIcon = field.isDeprecated ? TEXT('{D}') : '';
9499
const parts = stringifyWrappers(field.typeWrappers).map(TEXT);
95-
return canDisplayRow(field.type)
100+
return canDisplayRow(field)
96101
? `
97102
<TR>
98103
<TD ${HtmlId(field.id)} ALIGN="LEFT" PORT="${field.name}">

src/introspection/introspection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function markRelayTypes(schema: SimplifiedIntrospectionWithIds): void {
138138
return;
139139
}
140140

141-
const edgesType = connectionType.fields.edges.type
141+
const edgesType = connectionType.fields.edges.type;
142142
if (edgesType.kind !== 'OBJECT' || !edgesType.fields.node) {
143143
return;
144144
}

src/introspection/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type SimplifiedField<T> = {
1616
description: string;
1717
typeWrappers: ('NON_NULL' | 'LIST')[];
1818
isDeprecated: boolean;
19+
isHidden?: boolean;
1920
deprecationReason?: string;
2021
args: {
2122
[name: string]: SimplifiedArg;

0 commit comments

Comments
 (0)