Skip to content

Commit 0591186

Browse files
author
Vitaliy
authored
Merge pull request #125 from mmezhensky/issue-123-graphql-resolver-generation
#123: created GraphQl Resolver generation
2 parents db49b23 + f5f1421 commit 0591186

12 files changed

+651
-0
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
5959
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
6060
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
61+
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
6162
<add-to-group group-id="NewGroup" anchor="last"/>
6263
</group>
6364

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Resolve multiple requests.
3+
*
4+
* @param ContextInterface $context
5+
* @param Field $field
6+
* @param array $requests
7+
* @return BatchResponse
8+
*/
9+
public function resolve(
10+
ContextInterface $context,
11+
Field $field,
12+
array $requests
13+
): BatchResponse {
14+
// TODO: Implement resolve() method.
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
</body>
10+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
4+
#if (${NAMESPACE})
5+
6+
namespace ${NAMESPACE};
7+
8+
#end
9+
use Magento\Framework\GraphQl\Config\Element\Field;
10+
use Magento\Framework\GraphQl\Query\Resolver\BatchResolverInterface;
11+
use Magento\Framework\GraphQl\Query\Resolver\BatchResponse;
12+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
13+
14+
class ${NAME} implements BatchResolverInterface {
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
</body>
10+
</html>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation;
6+
7+
import com.intellij.ide.IdeView;
8+
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.psi.PsiDirectory;
11+
import com.magento.idea.magento2plugin.MagentoIcons;
12+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewGraphQlResolverDialog;
13+
import org.jetbrains.annotations.NotNull;
14+
15+
public class NewGraphQlResolverAction extends AnAction {
16+
public static String ACTION_NAME = "Magento 2 GraphQL Resolver";
17+
public static String ACTION_DESCRIPTION = "Create a new Magento 2 GraphQL Resolver";
18+
19+
NewGraphQlResolverAction() {
20+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
21+
}
22+
23+
@Override
24+
public void actionPerformed(@NotNull AnActionEvent e) {
25+
DataContext dataContext = e.getDataContext();
26+
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
27+
if (view == null) {
28+
return;
29+
}
30+
31+
Project project = CommonDataKeys.PROJECT.getData(dataContext);
32+
if (project == null) {
33+
return;
34+
}
35+
36+
PsiDirectory directory = view.getOrChooseDirectory();
37+
if (directory == null) {
38+
return;
39+
}
40+
41+
NewGraphQlResolverDialog.open(project, directory);
42+
}
43+
44+
@Override
45+
public boolean isDumbAware() {
46+
return false;
47+
}
48+
}
49+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation.data;
6+
7+
public class GraphQlResolverFileData {
8+
private String graphQlResolverDirectory;
9+
private String graphQlResolverClassName;
10+
private String graphQlResolverModule;
11+
private String graphQlResolverClassFqn;
12+
private String namespace;
13+
14+
public GraphQlResolverFileData(
15+
String graphQlResolverDirectory,
16+
String graphQlResolverClassName,
17+
String graphQlResolverModule,
18+
String graphQlResolverClassFqn,
19+
String namespace
20+
) {
21+
this.graphQlResolverDirectory = graphQlResolverDirectory;
22+
this.graphQlResolverClassName = graphQlResolverClassName;
23+
this.graphQlResolverModule = graphQlResolverModule;
24+
this.graphQlResolverClassFqn = graphQlResolverClassFqn;
25+
this.namespace = namespace;
26+
}
27+
28+
public String getGraphQlResolverClassName() {
29+
return graphQlResolverClassName;
30+
}
31+
32+
public String getGraphQlResolverDirectory() {
33+
return graphQlResolverDirectory;
34+
}
35+
36+
public String getGraphQlResolverModule() {
37+
return graphQlResolverModule;
38+
}
39+
40+
public String getGraphQlResolverClassFqn() { return graphQlResolverModule; }
41+
42+
public String getNamespace() {
43+
return namespace;
44+
}
45+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.magento.idea.magento2plugin.actions.generation.dialog.NewGraphQlResolverDialog">
3+
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="10" left="10" bottom="10" right="10"/>
5+
<constraints>
6+
<xy x="70" y="43" width="419" height="356"/>
7+
</constraints>
8+
<properties>
9+
<opaque value="true"/>
10+
<preferredSize width="420" height="120"/>
11+
<requestFocusEnabled value="true"/>
12+
</properties>
13+
<border type="none"/>
14+
<children>
15+
<grid id="90a70" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
16+
<margin top="0" left="0" bottom="0" right="0"/>
17+
<constraints>
18+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
19+
</constraints>
20+
<properties/>
21+
<border type="none"/>
22+
<children>
23+
<component id="b0da4" class="javax.swing.JLabel">
24+
<constraints>
25+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
26+
<preferred-size width="113" height="16"/>
27+
</grid>
28+
</constraints>
29+
<properties>
30+
<labelFor value="2d9cc"/>
31+
<text value="GraphQL Resolver Name"/>
32+
</properties>
33+
</component>
34+
<component id="1f03b" class="javax.swing.JTextField" binding="graphQlResolverClassName">
35+
<constraints>
36+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
37+
<preferred-size width="150" height="-1"/>
38+
</grid>
39+
</constraints>
40+
<properties/>
41+
<clientProperties>
42+
<html.disable class="java.lang.Boolean" value="true"/>
43+
</clientProperties>
44+
</component>
45+
<component id="29a9d" class="javax.swing.JTextField" binding="graphQlResolverParentDir">
46+
<constraints>
47+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
48+
<preferred-size width="150" height="-1"/>
49+
</grid>
50+
</constraints>
51+
<properties/>
52+
<clientProperties>
53+
<html.disable class="java.lang.Boolean" value="true"/>
54+
</clientProperties>
55+
</component>
56+
<component id="b5004" class="javax.swing.JLabel">
57+
<constraints>
58+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
59+
</constraints>
60+
<properties>
61+
<labelFor value="fdc52"/>
62+
<text value="GraphQL Resolver Directory"/>
63+
</properties>
64+
<clientProperties>
65+
<html.disable class="java.lang.Boolean" value="true"/>
66+
</clientProperties>
67+
</component>
68+
</children>
69+
</grid>
70+
<grid id="b0154" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
71+
<margin top="0" left="0" bottom="0" right="0"/>
72+
<constraints>
73+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
74+
</constraints>
75+
<properties/>
76+
<border type="none"/>
77+
<children>
78+
<vspacer id="28111">
79+
<constraints>
80+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
81+
</constraints>
82+
</vspacer>
83+
</children>
84+
</grid>
85+
<grid id="9ad5" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
86+
<margin top="0" left="0" bottom="0" right="0"/>
87+
<constraints>
88+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
89+
</constraints>
90+
<properties/>
91+
<border type="none"/>
92+
<children>
93+
<hspacer id="4aa6d">
94+
<constraints>
95+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
96+
</constraints>
97+
</hspacer>
98+
<grid id="f892c" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
99+
<margin top="0" left="0" bottom="0" right="0"/>
100+
<constraints>
101+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
102+
</constraints>
103+
<properties/>
104+
<border type="none"/>
105+
<children>
106+
<component id="20801" class="javax.swing.JButton" binding="buttonOK">
107+
<constraints>
108+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
109+
</constraints>
110+
<properties>
111+
<text value="OK"/>
112+
</properties>
113+
</component>
114+
<component id="1b860" class="javax.swing.JButton" binding="buttonCancel">
115+
<constraints>
116+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
117+
</constraints>
118+
<properties>
119+
<text value="Cancel"/>
120+
</properties>
121+
</component>
122+
</children>
123+
</grid>
124+
</children>
125+
</grid>
126+
</children>
127+
</grid>
128+
</form>

0 commit comments

Comments
 (0)