-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.xml
More file actions
1 lines (1 loc) · 43.2 KB
/
Copy pathindex.xml
File metadata and controls
1 lines (1 loc) · 43.2 KB
1
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GraphQL Java Kickstart</title><link>https://graphql-java-kickstart.github.io/</link><description>Recent content on GraphQL Java Kickstart</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 17 May 2021 07:00:00 -0500</lastBuildDate><atom:link href="https://graphql-java-kickstart.github.io/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting started</title><link>https://graphql-java-kickstart.github.io/servlet/getting-started/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/servlet/getting-started/</guid><description><p>A working version of this example can be found at <a href="https://github.com/graphql-java-kickstart/samples/tree/master/servlet-hello-world">https://github.com/graphql-java-kickstart/samples/tree/master/servlet-hello-world</a>.</p> <h2 id="build-with-gradle">Build with Gradle</h2> <p>First you set up a basic build script. You can use any build system you like, but the code you need to work with Gradle and Maven is included here.</p> <h3 id="create-a-gradle-build-file">Create a Gradle build file</h3> <p>Make sure <code>mavenCentral</code> is among your repositories. The example build script below uses <code>org.gretty</code> to provide a webserver to show a working example.</p></description></item><item><title>Getting started</title><link>https://graphql-java-kickstart.github.io/spring-boot/getting-started/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/spring-boot/getting-started/</guid><description><p>This project requires at least the following version:</p> <ul> <li>Java 17</li> <li>Spring Boot 3.x.x (<code>spring-boot-starter-web</code>)</li> </ul> <h2 id="quick-start">Quick start</h2> <p>To add <code>graphql-spring-boot</code> to your project and get started quickly, do the following.</p> <h3 id="build-with-gradle">Build with Gradle</h3> <p>Make sure <code>mavenCentral</code> is amongst your repositories:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-gradle" data-lang="gradle"><span style="display:flex;"><span>repositories <span style="color:#f92672">{</span> </span></span><span style="display:flex;"><span> mavenCentral<span style="color:#f92672">()</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> </span></span></code></pre></div><p>Add the respective starter dependencies you want to use:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-gradle" data-lang="gradle"><span style="display:flex;"><span>dependencies <span style="color:#f92672">{</span> </span></span><span style="display:flex;"><span> implementation <span style="color:#e6db74">&#39;com.graphql-java-kickstart:graphql-spring-boot-starter:15.0.0&#39;</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#75715e">// testing facilities </span></span></span><span style="display:flex;"><span> testImplementation <span style="color:#e6db74">&#39;com.graphql-java-kickstart:graphql-spring-boot-starter-test:15.0.0&#39;</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> </span></span></code></pre></div><h3 id="build-with-maven">Build with Maven</h3> <p>Add the respective starter dependencies you want to use:</p></description></item><item><title>Getting started</title><link>https://graphql-java-kickstart.github.io/tools/getting-started/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/getting-started/</guid><description><p>A working <a href="https://github.com/graphql-java-kickstart/samples/tree/master/tools-hello-world">Java Spring-Boot application</a> is provided, based off the <a href="https://github.com/graphql-java/graphql-java/blob/master/src/test/groovy/graphql/StarWarsSchema.java">Star Wars API</a> tests and <a href="https://github.com/graphql-java/graphql-java/blob/master/src/test/groovy/graphql/StarWarsData.groovy">test data</a>. If you&rsquo;re using Spring Boot, check out the <a href="https://github.com/graphql-java-kickstart/graphql-spring-boot">graphql-spring-boot-starter</a>!</p> <p>A working <a href="https://github.com/graphql-java-kickstart/graphql-java-tools/blob/master/src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt">Kotlin example</a> can be found in the tests.</p> <h2 id="quick-start">Quick start</h2> <p>To add <code>graphql-java-tools</code> to your project and get started quickly, do the following.</p> <h3 id="build-with-gradle">Build with Gradle</h3> <p>Make sure <code>mavenCentral</code> is amongst your repositories:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-gradle" data-lang="gradle"><span style="display:flex;"><span>repositories <span style="color:#f92672">{</span> </span></span><span style="display:flex;"><span> mavenCentral<span style="color:#f92672">()</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> </span></span></code></pre></div><p>Add the <code>graphql-java-tools</code> dependency:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-gradle" data-lang="gradle"><span style="display:flex;"><span>dependencies <span style="color:#f92672">{</span> </span></span><span style="display:flex;"><span> compile <span style="color:#e6db74">&#39;com.graphql-java-kickstart:graphql-java-tools:13.0.3&#39;</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> </span></span></code></pre></div><h3 id="build-with-maven">Build with Maven</h3> <p>Add the <code>graphql-java-tools</code> dependency:</p></description></item><item><title>Dataloaders</title><link>https://graphql-java-kickstart.github.io/servlet/dataloaders/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/servlet/dataloaders/</guid><description><p>It is possible to create context, and consequently dataloaders, in both a request scope and a per query scope by customizing <a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/context/GraphQLContextBuilder.java">GraphQLContextBuilder</a> and selecting the appropriate <a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/context/ContextSetting.java">ContextSetting</a> with the provided <a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/GraphQLConfiguration.java">GraphQLConfiguration</a>. A new <a href="https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoaderRegistry.java">DataLoaderRegistry</a> should be created in each call to the GraphQLContextBuilder, and the servlet will call the builder at the appropriate times. For example:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">CustomGraphQLContextBuilder</span> <span style="color:#66d9ef">implements</span> GraphQLServletContextBuilder { </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">private</span> <span style="color:#66d9ef">final</span> DataLoader userDataLoader; </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span> <span style="color:#a6e22e">CustomGraphQLContextBuilder</span>(DataLoader userDataLoader) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">userDataLoader</span> <span style="color:#f92672">=</span> userDataLoader; </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span> GraphQLContext <span style="color:#a6e22e">build</span>() { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">new</span> DefaultGraphQLContext(); </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span> GraphQLContext <span style="color:#a6e22e">build</span>(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> DefaultGraphQLServletContext.<span style="color:#a6e22e">createServletContext</span>() </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(httpServletRequest) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(httpServletResponse) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(buildDataLoaderRegistry()) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">build</span>(); </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span> GraphQLContext <span style="color:#a6e22e">build</span>(Session session, HandshakeRequest handshakeRequest) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> DefaultGraphQLWebSocketContext.<span style="color:#a6e22e">createWebSocketContext</span>() </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(session) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(handshakeRequest) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(buildDataLoaderRegistry()) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">build</span>(); </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">private</span> DataLoaderRegistry <span style="color:#a6e22e">buildDataLoaderRegistry</span>() { </span></span><span style="display:flex;"><span> DataLoaderRegistry registry <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> DataLoaderRegistry(); </span></span><span style="display:flex;"><span> registry.<span style="color:#a6e22e">register</span>(<span style="color:#e6db74">&#34;userDataLoader&#34;</span>, userDataLoader); </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> registry; </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p>It is then possible to access the <a href="https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoader.java">DataLoader</a> in the resolvers by accessing the <a href="https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoaderRegistry.java">DataLoaderRegistry</a> from context. For example:</p></description></item><item><title>Defining a schema</title><link>https://graphql-java-kickstart.github.io/tools/schema-definition/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/schema-definition/</guid><description><p>A <a href="http://graphql.org/learn/schema/">GraphQL schema</a> can be given either as raw strings:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#75715e">// My application class</span> </span></span><span style="display:flex;"><span>SchemaParser.<span style="color:#a6e22e">newParser</span>() </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">schemaString</span>(<span style="color:#e6db74">&#34;Query { }&#34;</span>) </span></span></code></pre></div><p>or as files on the classpath:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#75715e">// My application class</span> </span></span><span style="display:flex;"><span>SchemaParser.<span style="color:#a6e22e">newParser</span>() </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">file</span>(<span style="color:#e6db74">&#34;my-schema.graphqls&#34;</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#75715e">// my-schema.graphqls</span> </span></span><span style="display:flex;"><span>Query { } </span></span></code></pre></div><p>Multiple sources will be concatenated together in the order given, allowing you to modularize your schema if desired.</p> <h2 id="resolvers-and-data-classes">Resolvers and Data Classes</h2> <p>GraphQL Java Tools maps fields on your GraphQL objects to methods and properties on your java objects. For most scalar fields, a POJO with fields and/or getter methods is enough to describe the data to GraphQL. More complex fields (like looking up another object) often need more complex methods with state not provided by the GraphQL context (repositories, connections, etc). GraphQL Java Tools uses the concept of &ldquo;Data Classes&rdquo; and &ldquo;Resolvers&rdquo; to account for both of these situations.</p></description></item><item><title>Servlet Listener</title><link>https://graphql-java-kickstart.github.io/servlet/servlet-listener/</link><pubDate>Fri, 15 May 2020 09:28:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/servlet/servlet-listener/</guid><description><p>The GraphQL Servlet library allows you to add a <a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/core/GraphQLServletListener.java">Servlet Listener</a> for listening to the GraphQL request. It provides hooks into the servlet request execution (success, error, and finally):</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">MyServlet</span> <span style="color:#66d9ef">extends</span> GraphQLHttpServlet { </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">@Override</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">protected</span> GraphQLConfiguration <span style="color:#a6e22e">getConfiguration</span>() { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> GraphQLConfiguration.<span style="color:#a6e22e">with</span>(createSchema()) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(queryInvoker) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">with</span>(Arrays.<span style="color:#a6e22e">asList</span>(listener)) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">build</span>(); </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><h2 id="instrumentation">Instrumentation</h2> <p>The Servlet Listener listens to the servlet request, but not to the GraphQL query execution. If you want to listen to that you should use the <a href="https://www.graphql-java.com/documentation/v16/instrumentation/">Instrumentation</a> provided by GraphQL Java. You can extend <a href="https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/instrumentation/SimpleInstrumentation.java">SimpleInstrumentation</a> to quickly create a custom implementation and use it when creating the <code>GraphQLConfiguration</code>.</p></description></item><item><title>Schema parser options</title><link>https://graphql-java-kickstart.github.io/tools/schema-parser-options/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/schema-parser-options/</guid><description><p>For advanced use-cases, the schema parser can be tweaked to suit your needs. Use <code>SchemaParserOptions.newBuilder()</code> to build an options object to pass to the parser.</p> <p>Options:</p> <ul> <li> <p><code>contextClass</code>: If you use a custom context object to execute your queries, let the parser know about it so that it can add it to data fetchers as an argument.<br> Make sure to also provide your context instance to the execution input:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> executionInput <span style="color:#f92672">=</span> ExecutionInput.<span style="color:#a6e22e">newExecutionInput</span>() </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">query</span>(query) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">variables</span>(variables) </span></span><span style="display:flex;"><span> .<span style="color:#a6e22e">graphQLContext</span>(Map.<span style="color:#a6e22e">of</span>(CustomContext.<span style="color:#a6e22e">class</span>, context)); </span></span></code></pre></div></li> <li> <p><code>genericWrappers</code>: Allows defining your own generic classes that should be unwrapped when matching Java types to GraphQL types. You must supply the class and the index (zero-indexed) of the wrapped generic type. For example: If you want to unwrap type argument <code>T</code> of <code>Future&lt;T&gt;</code>, you must pass <code>Future.class</code> and <code>0</code>.</p></description></item><item><title>Relay</title><link>https://graphql-java-kickstart.github.io/tools/relay/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/relay/</guid><description><p>Relay requires quite some boilerplate type definitions to be defined. They are all the same apart from type of the node the Relay connection targets. This results in schemas with a lot of duplication, like the following:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-graphql" data-lang="graphql"><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">Query</span> { </span></span><span style="display:flex;"><span> users(first: <span style="color:#a6e22e">Int</span>, after: <span style="color:#a6e22e">String</span>): <span style="color:#a6e22e">UserConnection</span> </span></span><span style="display:flex;"><span> organizations(first: <span style="color:#a6e22e">Int</span>, after: <span style="color:#a6e22e">String</span>): <span style="color:#a6e22e">OrganizationConnection</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">UserConnection</span> { </span></span><span style="display:flex;"><span> edges: [UserEdge] </span></span><span style="display:flex;"><span> pageInfo: <span style="color:#a6e22e">PageInfo</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">UserEdge</span> { </span></span><span style="display:flex;"><span> cursor: <span style="color:#a6e22e">String</span> </span></span><span style="display:flex;"><span> node: <span style="color:#a6e22e">User</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">PageInfo</span> { </span></span><span style="display:flex;"><span> hasPreviousPage: <span style="color:#a6e22e">Boolean</span>! </span></span><span style="display:flex;"><span> hasNextPage: <span style="color:#a6e22e">Boolean</span>! </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">User</span> { </span></span><span style="display:flex;"><span> id: <span style="color:#a6e22e">ID</span>! </span></span><span style="display:flex;"><span> name: <span style="color:#a6e22e">String</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">OrganizationConnection</span> { </span></span><span style="display:flex;"><span> edges: [OrganizationEdge] </span></span><span style="display:flex;"><span> pageInfo: <span style="color:#a6e22e">PageInfo</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">OrganizationEdge</span> { </span></span><span style="display:flex;"><span> cursor: <span style="color:#a6e22e">String</span> </span></span><span style="display:flex;"><span> node: <span style="color:#a6e22e">Organization</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">Organization</span> { </span></span><span style="display:flex;"><span> id: <span style="color:#a6e22e">ID</span>! </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><h2 id="using-the-type-definition-factory">Using the Type Definition Factory</h2> <p>In version 5.4 of <code>graphql-java-tools</code> the <a href="https://graphql-java-kickstart.github.io/tools/type-definition-factory/">Type Definition Factory</a> has been introduced. This has been added with this particular use case in mind, but can be used for any type of definition that you&rsquo;d want to add dynamically instead of defining it statically in the SDL.</p></description></item><item><title>Type Definition Factory</title><link>https://graphql-java-kickstart.github.io/spring-boot/type-definition-factory/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/spring-boot/type-definition-factory/</guid><description><p>The <strong>Type Definition Factory</strong> has been added with to be able to dynamically add type definitions to the schema instead of having to define them manually in the SDL. There are a couple of use cases where the types that have to be defined are very much alike and only certain parts are different. For example the connection and edge types used by <a href="https://graphql-java-kickstart.github.io/tools/relay/">Relay</a>. Since generics isn&rsquo;t supported in the definition language this type definition factory has been added.</p></description></item><item><title>Type Definition Factory</title><link>https://graphql-java-kickstart.github.io/tools/type-definition-factory/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/type-definition-factory/</guid><description><p>The <strong>Type Definition Factory</strong> has been added to allow to dynamically add type definitions to the schema instead of having to define them manually in the SDL. There are a couple of use cases where the types that have to be defined are very much alike and only certain parts are different. For example the connection and edge types used by <a href="https://graphql-java-kickstart.github.io/tools/relay/">Relay</a>. Since generics aren&rsquo;t supported in the definition language this type definition factory has been added.</p></description></item><item><title>Directives</title><link>https://graphql-java-kickstart.github.io/spring-boot/directives/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/spring-boot/directives/</guid><description><p>See <a href="https://www.graphql-java.com/documentation/v16/sdl-directives/">Schema Directives</a> for a detailed explanation about directives including examples on how to define them in the SDL and to create the required classes.</p> <p>To add your custom <code>SchemaDirectiveWiring</code> to <code>graphql-spring-boot</code> create a bean of type <code>SchemaDirective</code> to have it automatically passed along to the <code>SchemaParser</code></p> <pre tabindex="0"><code>SchemaDirective.create(&#34;uppercase&#34;, new UppercaseDirective()) </code></pre><h2 id="basic-usage">Basic usage</h2> <p>Let&rsquo;s say you defined a custom directive to make text uppercase in a resource <code>schema.graphqls</code>:</p> <pre tabindex="0"><code>directive @uppercase on FIELD_DEFINITION type Query { hello: String @uppercase } </code></pre><p>And the actual implementation is the following:</p></description></item><item><title>Directives</title><link>https://graphql-java-kickstart.github.io/tools/directives/</link><pubDate>Wed, 07 Nov 2018 00:11:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/tools/directives/</guid><description><p>See <a href="https://www.graphql-java.com/documentation/v16/sdl-directives/">Schema Directives</a> for a detailed explanation about directives including examples on how to define them in the SDL and to create the required classes.</p> <p>To add your custom <code>SchemaDirectiveWiring</code> to <code>graphql-java-tools</code> pass it along when creating the <code>SchemaParser</code> using</p> <pre tabindex="0"><code>SchemaParser.newParser().directive(&#34;name&#34;, new MySchemaDirectiveWiring()).build() </code></pre><h2 id="basic-usage">Basic usage</h2> <p>Let&rsquo;s say you defined a custom directive to make text uppercase in a resource <code>schema.graphqls</code>:</p> <pre tabindex="0"><code>directive @uppercase on FIELD_DEFINITION type Query { hello: String @uppercase } </code></pre><p>And the actual implementation is the following:</p></description></item><item><title>Embedded Editors</title><link>https://graphql-java-kickstart.github.io/spring-boot/embedded-editors/</link><pubDate>Mon, 17 May 2021 07:00:00 -0500</pubDate><guid>https://graphql-java-kickstart.github.io/spring-boot/embedded-editors/</guid><description><p>The following GraphQL Embedded Editors are bundled for convenience:</p> <ul> <li><a href="#altair">Altair</a> <ul> <li><a href="#configuration-parameters">Configuration Parameters</a></li> </ul> </li> <li><a href="#graphql-playground">GraphQL Playground</a> <ul> <li><a href="#configuration-parameters-1">Configuration Parameters</a></li> </ul> </li> <li><a href="#graphiql">GraphiQL</a> <ul> <li><a href="#configuration-parameters-2">Configuration Parameters</a></li> </ul> </li> <li><a href="#graphql-voyager">GraphQL Voyager</a> <ul> <li><a href="#configuration-parameters-3">Configuration Parameters</a></li> </ul> </li> </ul> <h2 id="altair">Altair</h2> <p><a href="https://github.com/imolorhe/altair">Altair</a> becomes accessible at the root <code>/altair</code> if the <code>graphql.altair.enabled</code> property is true.</p> <p>Note that GraphQL server must be available at <code>/graphql/\*</code> context to be discovered by Altair.</p> <h3 id="configuration-parameters">Configuration Parameters</h3> <p>Available Spring Boot configuration parameters (either <code>application.yml</code> or <code>application.properties</code>):</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">graphql</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">altair</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">enabled</span>: <span style="color:#66d9ef">true</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">mapping</span>: <span style="color:#ae81ff">/altair</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">subscriptions</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">timeout</span>: <span style="color:#ae81ff">30</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">reconnect</span>: <span style="color:#66d9ef">false</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">static</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">base-path</span>: <span style="color:#ae81ff">/</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">page-title</span>: <span style="color:#ae81ff">Altair</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">cdn</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">enabled</span>: <span style="color:#66d9ef">false</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">version</span>: <span style="color:#ae81ff">4.0.2</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">options</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">endpoint-url</span>: <span style="color:#ae81ff">/graphql</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">subscriptions-endpoint</span>: <span style="color:#ae81ff">/subscriptions</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-settings</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">theme</span>: <span style="color:#ae81ff">dracula</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-headers</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">Authorization</span>: <span style="color:#e6db74">&#34;Bearer &lt;your-token&gt;&#34;</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">resources</span>: </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-query</span>: <span style="color:#ae81ff">defaultQuery.graphql</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-variables</span>: <span style="color:#ae81ff">variables.graphql</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-pre-request-script</span>: <span style="color:#ae81ff">pre-request.graphql</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">initial-post-request-script</span>: <span style="color:#ae81ff">post-request.graphql</span> </span></span></code></pre></div><h2 id="graphql-playground">GraphQL Playground</h2> <p><a href="https://github.com/prisma/graphql-playground">GraphQL Playground</a> becomes accessible at root <code>/playground</code> (or as configured in <code>graphql.playground.mapping</code>) if the <code>graphql.playground.enabled</code> property is true.</p></description></item><item><title>OSGi</title><link>https://graphql-java-kickstart.github.io/servlet/osgi/</link><pubDate>Fri, 15 May 2020 09:28:02 +0100</pubDate><guid>https://graphql-java-kickstart.github.io/servlet/osgi/</guid><description><p>The <a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/OsgiGraphQLHttpServlet.java">OsgiGraphQLHttpServlet</a> uses a &ldquo;provider&rdquo; model to supply the servlet with the required objects:</p> <ul> <li><a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/osgi/GraphQLQueryProvider.java">GraphQLQueryProvider</a>: Provides query fields to the GraphQL schema.</li> <li><a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/osgi/GraphQLMutationProvider.java">GraphQLMutationProvider</a>: Provides mutation fields to the GraphQL schema.</li> <li><a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/osgi/GraphQLTypesProvider.java">GraphQLTypesProvider</a>: Provides type information to the GraphQL schema.</li> <li><a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/ExecutionStrategyProvider.java">ExecutionStrategyProvider</a>: Provides an execution strategy for running each query.</li> <li><a href="https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/context/GraphQLServletContextBuilder.java">GraphQLContextBuilder</a>: Builds a context for running each query.</li> </ul> <h2 id="examples">Examples</h2> <p>You can now find some example on how to use graphql-java-servlet.</p> <h3 id="requirements">Requirements</h3> <p>The OSGi examples use Maven as a build tool because it requires plugins that are not (yet) available for Gradle. Therefore you will need Maven 3.2+.</p></description></item></channel></rss>