-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #164: descriptions of GraphQL items is now in the generated code
- Loading branch information
etienne-sf
committed
Dec 3, 2022
1 parent
560a39d
commit 747a1c2
Showing
25 changed files
with
691 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...en-plugin-logic/src/main/java/com/graphql_java_generator/plugin/language/Description.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* | ||
*/ | ||
package com.graphql_java_generator.plugin.language; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* This class matches the description of a GraphQL item, as described in the GraphQL schema. It allows several | ||
* capabilities for use in the template, for code or schema generation | ||
* | ||
* @author etienne-sf | ||
*/ | ||
public class Description { | ||
|
||
/** The description as it has been read from the source GraphQL schema */ | ||
final graphql.language.Description description; | ||
|
||
/** The decomposition of the description in lines, without the EOL character(s) */ | ||
List<String> lines = null; | ||
|
||
public Description(graphql.language.Description description2) { | ||
this.description = description2; | ||
} | ||
|
||
/** | ||
* Returns the content of the description | ||
* | ||
* @return | ||
*/ | ||
public String getContent() { | ||
return description.getContent(); | ||
} | ||
|
||
public boolean isMultiLine() { | ||
return description.isMultiLine(); | ||
} | ||
|
||
/** | ||
* Returns an array of the lines of this description. This array contains at least one item. | ||
* | ||
* @return | ||
*/ | ||
public List<String> getLines() { | ||
if (lines == null) { | ||
if (description.isMultiLine()) { | ||
try (BufferedReader sr = new BufferedReader(new StringReader(description.getContent()))) { | ||
lines = sr.lines().collect(Collectors.toList()); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e.getMessage(), e); | ||
} | ||
} else { | ||
lines = new ArrayList<String>(1); | ||
lines.add(description.getContent()); | ||
} | ||
} | ||
return lines; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.