Skip to content

Commit f11362a

Browse files
committed
Skip errors on introspection (#548)
1 parent 4ba6717 commit f11362a

File tree

4 files changed

+3104
-2
lines changed

4 files changed

+3104
-2
lines changed

src/main/com/intellij/lang/jsgraphql/ide/introspection/GraphQLIntrospectionService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,21 @@ public String printIntrospectionAsGraphQL(@NotNull Map<String, Object> introspec
349349
for (GraphQLError error : errors) {
350350
LOG.warn(error.getMessage());
351351
}
352-
throw new SchemaProblem(errors);
353352
}
354353

355-
return new SchemaPrinter(myProject, options).print(schemaInfo.getSchema());
354+
try {
355+
return new SchemaPrinter(myProject, options).print(schemaInfo.getSchema());
356+
}
357+
catch (ProcessCanceledException e) {
358+
throw e;
359+
}
360+
catch (Exception e) {
361+
if (!errors.isEmpty()) {
362+
throw new SchemaProblem(errors);
363+
} else {
364+
throw e;
365+
}
366+
}
356367
}
357368

358369
@SuppressWarnings("unchecked")

src/test/com/intellij/lang/jsgraphql/introspection/GraphQLIntrospectionServiceTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public void testGithubSchema() {
5151
);
5252
}
5353

54+
public void testPrintIntrospectionWithUndefinedDirectives() {
55+
doTest("schemaWithUndefinedDirectives.json", "schemaWithUndefinedDirectives.graphql");
56+
}
57+
5458
private void doTest(@NotNull String source, @NotNull String expected) {
5559
myFixture.configureByText(
5660
"result.graphql",
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
schema {
2+
query: Query
3+
}
4+
5+
"An object with an ID"
6+
interface Node {
7+
"The ID of the object."
8+
id: ID!
9+
}
10+
11+
type CategoryNode implements Node {
12+
"The ID of the object."
13+
id: ID!
14+
ingredients(after: String, before: String, category: ID, category_Name: String, first: Int, last: Int, name: String, name_Icontains: String, name_Istartswith: String, notes: String, notes_Icontains: String, offset: Int): IngredientNodeConnection!
15+
name: String!
16+
}
17+
18+
type CategoryNodeConnection {
19+
"Contains the nodes in this connection."
20+
edges: [CategoryNodeEdge]!
21+
"Pagination data for this connection."
22+
pageInfo: PageInfo!
23+
}
24+
25+
"A Relay edge containing a `CategoryNode` and its cursor."
26+
type CategoryNodeEdge {
27+
"A cursor for use in pagination"
28+
cursor: String!
29+
"The item at the end of the edge"
30+
node: CategoryNode
31+
}
32+
33+
"Debugging information for the current query."
34+
type DjangoDebug {
35+
"Executed SQL queries for this API query."
36+
sql: [DjangoDebugSQL]
37+
}
38+
39+
"Represents a single database query made to a Django managed DB."
40+
type DjangoDebugSQL {
41+
"The Django database alias (e.g. 'default')."
42+
alias: String!
43+
"Duration of this database query in seconds."
44+
duration: Float!
45+
"Postgres connection encoding if available."
46+
encoding: String
47+
"Whether this database query was a SELECT."
48+
isSelect: Boolean!
49+
"Whether this database query took more than 10 seconds."
50+
isSlow: Boolean!
51+
"Postgres isolation level if available."
52+
isoLevel: String
53+
"JSON encoded database query parameters."
54+
params: String!
55+
"The raw SQL of this query, without params."
56+
rawSql: String!
57+
"The actual SQL sent to this database."
58+
sql: String
59+
"Start time of this database query."
60+
startTime: Float!
61+
"Stop time of this database query."
62+
stopTime: Float!
63+
"Postgres transaction ID if available."
64+
transId: String
65+
"Postgres transaction status if available."
66+
transStatus: String
67+
"The type of database being used (e.g. postrgesql, mysql, sqlite)."
68+
vendor: String!
69+
}
70+
71+
type IngredientNode implements Node {
72+
category: CategoryNode!
73+
"The ID of the object."
74+
id: ID!
75+
name: String!
76+
notes: String
77+
usedBy(after: String, before: String, first: Int, ingredient_Name: String, ingredient_Name_Icontains: String, ingredient_Name_Istartswith: String, last: Int, offset: Int, recipe: ID, recipe_Title_Icontains: String): RecipeIngredientNodeConnection!
78+
}
79+
80+
type IngredientNodeConnection {
81+
"Contains the nodes in this connection."
82+
edges: [IngredientNodeEdge]!
83+
"Pagination data for this connection."
84+
pageInfo: PageInfo!
85+
}
86+
87+
"A Relay edge containing a `IngredientNode` and its cursor."
88+
type IngredientNodeEdge {
89+
"A cursor for use in pagination"
90+
cursor: String!
91+
"The item at the end of the edge"
92+
node: IngredientNode
93+
}
94+
95+
"The Relay compliant `PageInfo` type, containing data necessary to paginate this connection."
96+
type PageInfo {
97+
"When paginating forwards, the cursor to continue."
98+
endCursor: String
99+
"When paginating forwards, are there more items?"
100+
hasNextPage: Boolean!
101+
"When paginating backwards, are there more items?"
102+
hasPreviousPage: Boolean!
103+
"When paginating backwards, the cursor to continue."
104+
startCursor: String
105+
}
106+
107+
type Query {
108+
_debug: DjangoDebug
109+
allCategories(after: String, before: String, first: Int, ingredients: [ID], last: Int, name: String, offset: Int): CategoryNodeConnection
110+
allIngredients(after: String, before: String, category: ID, category_Name: String, first: Int, last: Int, name: String, name_Icontains: String, name_Istartswith: String, notes: String, notes_Icontains: String, offset: Int): IngredientNodeConnection
111+
allRecipeingredients(after: String, before: String, first: Int, ingredient_Name: String, ingredient_Name_Icontains: String, ingredient_Name_Istartswith: String, last: Int, offset: Int, recipe: ID, recipe_Title_Icontains: String): RecipeIngredientNodeConnection
112+
allRecipes(after: String, amounts: [ID], before: String, first: Int, last: Int, offset: Int, title: String): RecipeNodeConnection
113+
category(
114+
"The ID of the object"
115+
id: ID!
116+
): CategoryNode
117+
ingredient(
118+
"The ID of the object"
119+
id: ID!
120+
): IngredientNode
121+
recipe(
122+
"The ID of the object"
123+
id: ID!
124+
): RecipeNode
125+
recipeingredient(
126+
"The ID of the object"
127+
id: ID!
128+
): RecipeIngredientNode
129+
}
130+
131+
type RecipeIngredientNode implements Node {
132+
amount: Float!
133+
"The ID of the object."
134+
id: ID!
135+
ingredient: IngredientNode!
136+
recipe: RecipeNode!
137+
unit: RecipeIngredientUnit!
138+
}
139+
140+
type RecipeIngredientNodeConnection {
141+
"Contains the nodes in this connection."
142+
edges: [RecipeIngredientNodeEdge]!
143+
"Pagination data for this connection."
144+
pageInfo: PageInfo!
145+
}
146+
147+
"A Relay edge containing a `RecipeIngredientNode` and its cursor."
148+
type RecipeIngredientNodeEdge {
149+
"A cursor for use in pagination"
150+
cursor: String!
151+
"The item at the end of the edge"
152+
node: RecipeIngredientNode
153+
}
154+
155+
type RecipeNode implements Node {
156+
amounts(after: String, before: String, first: Int, ingredient_Name: String, ingredient_Name_Icontains: String, ingredient_Name_Istartswith: String, last: Int, offset: Int, recipe: ID, recipe_Title_Icontains: String): RecipeIngredientNodeConnection!
157+
"The ID of the object."
158+
id: ID!
159+
instructions: String!
160+
title: String!
161+
}
162+
163+
type RecipeNodeConnection {
164+
"Contains the nodes in this connection."
165+
edges: [RecipeNodeEdge]!
166+
"Pagination data for this connection."
167+
pageInfo: PageInfo!
168+
}
169+
170+
"A Relay edge containing a `RecipeNode` and its cursor."
171+
type RecipeNodeEdge {
172+
"A cursor for use in pagination"
173+
cursor: String!
174+
"The item at the end of the edge"
175+
node: RecipeNode
176+
}
177+
178+
"An enumeration."
179+
enum RecipeIngredientUnit {
180+
"Kilograms"
181+
KG
182+
"Litres"
183+
L
184+
"Shots"
185+
ST
186+
"Units"
187+
UNIT
188+
}

0 commit comments

Comments
 (0)