<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Juan Pablo Paillet on Medium]]></title>
        <description><![CDATA[Stories by Juan Pablo Paillet on Medium]]></description>
        <link>https://medium.com/@juanpablopaillet?source=rss-cc9e155acaf6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PzirbCO0zi0GrTQT</url>
            <title>Stories by Juan Pablo Paillet on Medium</title>
            <link>https://medium.com/@juanpablopaillet?source=rss-cc9e155acaf6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:28:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juanpablopaillet/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From GraphQL types to a PostgreSQL API with Simfinity.js]]></title>
            <link>https://medium.com/@juanpablopaillet/from-graphql-types-to-a-postgresql-api-with-simfinity-js-3bc7ef31fc7b?source=rss-cc9e155acaf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bc7ef31fc7b</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Juan Pablo Paillet]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 05:52:08 GMT</pubDate>
            <atom:updated>2026-09-16T05:55:01.947Z</atom:updated>
            <content:encoded><![CDATA[<p>A series catalog starts with a small domain: a serie has a name, and each season belongs to a serie. Even that model needs list queries, create/update/delete operations, relationship resolvers, validation and database storage.</p><p><a href="https://simtlix.github.io/simfinity.js/">Simfinity.js</a> generates those recurring pieces from GraphQL object types. Version 3.2.0 provides MongoDB/Mongoose and PostgreSQL adapters, plus an optional package for exposing GraphQL operations as MCP tools. The project is open source under Apache-2.0.</p><p>This walkthrough uses the published PostgreSQL starter. It includes a nested series/season example, so there is a relationship to inspect as well as a working API.</p><h3>Start with the domain</h3><p>The type definition uses the standard graphql package. A minimal entity looks like this:</p><pre>import {<br>  GraphQLID,<br>  GraphQLNonNull,<br>  GraphQLObjectType,<br>  GraphQLString,<br>} from &#39;graphql&#39;;</pre><pre>const SerieType = new GraphQLObjectType({<br>  name: &#39;Serie&#39;,<br>  fields: {<br>    id: { type: GraphQLID },<br>    name: { type: new GraphQLNonNull(GraphQLString) },<br>  },<br>});</pre><p>Register the type with the PostgreSQL runtime, supplying the singular and plural operation names:</p><pre>import pg from &#39;pg&#39;;<br>import { createPostgres } from &#39;@simtlix/simfinity-postgres&#39;;</pre><pre>const pool = new pg.Pool({<br>  connectionString: process.env.DATABASE_URL,<br>});<br>const simfinity = createPostgres({ pool, schema: &#39;series_api&#39; });</pre><pre>simfinity.connect(null, SerieType, &#39;serie&#39;, &#39;series&#39;);<br>const schema = simfinity.createSchema();<br>await simfinity.initializeDatabase({ mode: &#39;create&#39; });</pre><p>The resulting schema can be served through GraphQL Yoga. The downloaded starter includes that server setup, shutdown handling, a Season type and a controller. The snippets above show the core registration flow; the starter is the complete application.</p><h3>Run the released starter</h3><p>Use Node.js 22+ for the starter and PostgreSQL 15+. Download and extract the <a href="https://simtlix.github.io/simfinity.js/releases/simfinity-3.2.0-starters.zip">v3.2.0 starter archive</a>, then enter its postgres directory:</p><pre>cd simfinity-3.2.0-starters/postgres<br>npm install</pre><p>For a disposable local database, run:</p><pre>docker run --name simfinity-postgres-demo -e POSTGRES_PASSWORD=simfinity -e POSTGRES_DB=series -p 127.0.0.1:5432:5432 -d postgres:18-alpine</pre><p>In a POSIX shell, set the connection string and start the app:</p><pre>export DATABASE_URL=&#39;postgresql://postgres:simfinity@127.0.0.1:5432/series&#39;<br>npm start</pre><p>In PowerShell, use $env:DATABASE_URL = &#39;postgresql://postgres:simfinity@127.0.0.1:5432/series&#39; before npm start. If port 5432 is occupied, choose another host port and update the connection string. These credentials are for the disposable local example.</p><p>Open http://127.0.0.1:4000/graphql. Create a serie and its first season together:</p><pre>mutation {<br>  addserie(input: {<br>    name: &quot;The Expanse&quot;<br>    seasons: { added: [{ number: 1 }] }<br>  }) {<br>    id<br>    name<br>    createdBy<br>    seasons { id number }<br>  }<br>}</pre><p>Then read it back:</p><pre>query {<br>  series {<br>    name<br>    seasons { number }<br>  }<br>}</pre><p>The generated relationship resolves the season from its parent. PostgreSQL also has a real foreign key from the season’s serie column to the serie table. The API relationship and the database constraint come from the relationship metadata in the type definitions.</p><h3>Add application rules where they belong</h3><p>Generated CRUD is the starting point. Controllers and lifecycle hooks let you add domain behavior; validators, query scopes, state transitions and authorization rules provide other extension points.</p><p>Authentication remains application-owned. Configure the authorization policy and trusted request context for your deployment. The starter’s fixed quickstart-user context is demonstration code, not a login system.</p><p>Storage initialization is explicit. create mode creates missing generated objects and checks existing definitions; validate mode checks the schema without DDL. Schema evolution still needs deliberate migrations.</p><h3>Expose selected operations to an MCP client</h3><p>The optional @simtlix/simfinity-mcp package works with either database adapter. Once the application has initialized its GraphQL schema, tool definitions can be generated from selected operations:</p><pre>import { generateMCPTools } from &#39;@simtlix/simfinity-mcp&#39;;</pre><pre>const { tools } = generateMCPTools(schema, {<br>  include: [&#39;series&#39;],<br>  limits: {<br>    maxPageSize: 100,<br>    defaultPagination: { page: 1, size: 20 },<br>  },<br>});</pre><pre>console.log(tools.map((tool) =&gt; tool.name));</pre><p>Install that package separately when needed. Tool generation needs GraphQL; server/transport factories also use the optional MCP SDK. The <a href="https://simtlix.github.io/simfinity.js/guide/mcp.html">MCP guide</a> covers transports, trusted context and authorization.</p><h3>Choosing a backend</h3><p>Choose the adapter during application startup. PostgreSQL uses UUID identities, SQL constraints and its own native Model/Session APIs. MongoDB uses Mongoose, and generated mutations require a replica set or sharded cluster. Selecting an adapter does not migrate an existing database or translate arbitrary Mongoose calls into SQL.</p><p>Start with the <a href="https://simtlix.github.io/simfinity.js/guide/postgresql.html">PostgreSQL quick start</a>, review the <a href="https://simtlix.github.io/simfinity.js/compatibility.html">compatibility boundaries</a>, or explore the larger <a href="https://github.com/simtlix/series-sample">Series Sample Project</a>.</p><p><a href="https://github.com/simtlix/simfinity.js">Source code and issues</a></p><p>Disclosure: this project article was prepared with AI assistance and checked against the public 3.2.0 packages and documentation. The downloaded PostgreSQL starter was exercised locally with a nested create, query readback and database foreign-key inspection.</p><p>Originally published on <a href="https://dev.to/pailletjuanpablo/from-graphql-types-to-a-postgresql-api-with-simfinityjs-i6k">DEV Community</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bc7ef31fc7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>