diff --git a/deno.json b/deno.json index d9a27b3..3843550 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@joyautomation/tentacle", - "version": "0.0.43", + "version": "0.0.44", "description": "Tentacle is a modern soft PLC", "author": "Joy Automation", "license": "Apache-2.0", diff --git a/plc/graphql.ts b/plc/graphql.ts index 25dad9c..dcc4d1d 100644 --- a/plc/graphql.ts +++ b/plc/graphql.ts @@ -19,6 +19,8 @@ import { isSourceRedis, isVariableModbusSourceRuntime, isVariableOpcuaSourceRuntime, + isVariableRedisSourceRuntime, + type PlcVariableRedisSourceRuntime, type PlcSource, type PlcSourceRuntime, type PlcSources, @@ -82,6 +84,9 @@ export function addPlcToSchema< const PlcRuntimeVariableMqttSourceRef = builder.objectRef< PlcVariableMqttSourceRuntime >("PlcVariableMqttSourceRuntime"); + const PlcRuntimeVariableRedisSourceRef = builder.objectRef< + PlcVariableRedisSourceRuntime + >("PlcVariableRedisSourceRuntime"); const PlcRuntimeVariableErrorRef = builder.objectRef<{ error: string | null; message?: string | null; @@ -122,6 +127,7 @@ export function addPlcToSchema< PlcRuntimeVariableOpcuaSourceRef, PlcRuntimeVariableRestSourceRef, PlcRuntimeVariableMqttSourceRef, + PlcRuntimeVariableRedisSourceRef, ], resolveType: (source) => { if (isSourceModbus(source)) { @@ -136,6 +142,9 @@ export function addPlcToSchema< if (isSourceMqtt(source)) { return "PlcVariableMqttSourceRuntime"; } + if (isSourceRedis(source)) { + return "PlcVariableRedisSourceRuntime"; + } return undefined; }, } @@ -320,6 +329,16 @@ export function addPlcToSchema< }), }), }); + PlcRuntimeVariableRedisSourceRef.implement({ + fields: (t) => ({ + id: t.string({ + resolve: (parent) => parent.id.toString(), + }), + type: t.exposeString("type"), + key: t.exposeString("key"), + bidirectional: t.exposeBoolean("bidirectional"), + }), + }); PlcRuntimeVariableRef.implement({ fields: (t) => ({ id: t.exposeString("id"), @@ -364,6 +383,9 @@ export function addPlcToSchema< if (isVariableMqttSourceRuntime(source)) { return source; } + if (isVariableRedisSourceRuntime(source)) { + return source; + } } return null; },