prisma-select issue for custom output path - microservices

I am getting the below error when I try to use
const select = new PrismaSelect(info).value;
[Nest] 65877 - 17/05/2021, 16:45:13 [ExceptionsHandler] Cannot find module '.prisma/client'
My PrismaClient is in a custom path rather than the default, as I am using a monorepo for multiple microservices.
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "darwin"]
output = "../src/.generated/prisma/client"
}
Is there a way to point PrismaSelect to the correct Client?

The solution was shared by the author of the package
Import custom instance of Prisma Client
import { Prisma } from '../../.generated/prisma/client';
Pass dmmf object to PrismaSelect constructor
const select = new PrismaSelect(info, { dmmf: [Prisma.dmmf] }).value;

Related

gRPC read method options before launching server

I'm currently trying to add scopes to secure my gRPC methods exposition and I'm using custom scopes for each methods.
Here is my scope class:
syntax = "proto3";
package grpc.proto.scopes;
import "google/protobuf/descriptor.proto";
extend google.protobuf.MethodOptions {
string scopes = 50000;
}
And I'm using it on my service scheme:
syntax = "proto3";
import "grpc/proto/scopes.proto";
package service;
service Service1 {
rpc Get(Request) returns (Response) {
option(grpc.proto.scopes.scopes) = "service1.feature.read";
}
rpc Post(Request) returns (Response) {
option(grpc.proto.scopes.scopes) = "service1.feature.write";
}
}
But my problem is the following:
server := grpc.NewServer([...my interceptor which uses my scopes...])
// <-- I must initialize my server with my interceptor but I need to have an access to the registry to retrieve scopes
proto.RegisterService1Server(server, s) // <-- Schemes are available on registry only on this line
I cannot initialize my scopes interceptor with proto shemes' scope because they are available only when they are registered on the server. But I can't initialize my server without my interceptor, so I'm blocked.
I can handle scope on the fly inside my interceptor with protoregistry.GlobalFiles.FindDescriptorByName but it will decrease performances.
Is there any way to get my shemes' scopes before initializing my server?

How to create a NativeView in Nativescript-Angular?

I'm developing a mobile App with Nativescript and Angular, but I've a problem to create an headerView to add inside the CFAlertDialog (I'm using the plugin nativescript-cfalert-dialog).
I created a service to inject to several components in my app, which is something like this
import * as application from 'tns-core-modules/application'
#Injectable()
export class PlayerDialogService {
...
constructor() {
const context = application.android.context as android.content.Context;
this.generateAndroidNativeView(context)
}
private generateAndroidNativeView(context: android.content.Context) {
this.usernameLabel = new android.widget.TextView(context)
this.usernameLabel.setTextSize(20)
this.fullNameLabel = new android.widget.TextView(context)
this.fullNameLabel.setTextSize(16)
this.playerImage = new android.widget.ImageView(context)
this.playerImage.setMaxWidth(48)
this.playerImage.setMaxHeight(48)
this.textStackLayout = new android.widget.LinearLayout(context)
this.textStackLayout.addView(this.usernameLabel)
this.textStackLayout.addView(this.fullNameLabel)
this.stackLayout = new android.widget.LinearLayout(context)
this.stackLayout.addView(this.playerImage)
this.stackLayout.addView(this.textStackLayout)
}
}
Fact is that everytime the dialog is loaded (I open a component/view that has the PlayerDialogService injected), I get this error:
JS: ERROR TypeError: Cannot read property 'usernameLabel' of undefined
I'm afraid I'm not passing the correct Context (despite it's not an empty object, nor an undefined one), but has a constructor included. So... what am I missing?

Is it possible to recreate `schema.graphql` file from a schema uploaded to Apollo Engine?

After having pushed a schema to Apollo Engine, is it possible to recreate the schema.graphql that was used to push the schema in the first place?
It seems that the best I can get is a JSON version of the schema with obtained with apollo client:download-schema.
You can turn any schema introspection result into SDL using the core library:
const { buildClientSchema, printSchema } = require('graphql')
const introspectionResult = require('./schema.json')
const schema = buildClientSchema(introspectionResult)
const sdl = printSchema(schema)

Updating graphql schema without a server restart in apollo 2

My project has a declarative way of defining schema and resolvers, which is maintained in a separate repository. My graphql server polls the result of this to look for updates to the schema.
Using apollo-server-express#1, I had direct access to the graphqlExpress middleware, so when the schema changed I could construct a new instance of it and throw away the old one, something like this
const { graphqlExpress } = require('apollo-server-express');
let api;
const constructAPI = () => {
try {
const newSchema = createSchema();
api = graphqlExpress(({ headers }) => ({
schema: newSchema,
}));
logger.info({ event: 'GRAPHQL_SCHEMA_UPDATED' });
};
schemaPoller.on('change', constructAPI);
module.exports = router => {
// Note that we wrap the api controller in a function that passes
// the original args through because a new api controller is generated
// every time the schema changes. We can't pass express a direct
// reference to the api controller on startup, or it will
// never update the reference to point at the latest version of the
// controller using the latest schema
router
.route('/')
.get((...args) => api(...args))
.post((...args) => api(...args));
return router;
};
In apollo-server-express#2, access to the middleware is hidden away, and there are 2 new, more declarative ways of using the library, neither of which - at first glance - appear compatible with updating the schema without stopping the server, fetching the new schema and starting again with the new data, which is downtime I'd like to avoid.
Can anyone suggest a way of getting this setup to work with apollo#2?

fhir-net-api (STU3) - Validating

I have been using the Hl7.org tool org.hl7.fhir.validator.jar file to validate my messages but I would like to add this function it to my .Net project. Once I parse the message is there a class I can call to validate the Structure.
Is there a validate FHIR class in fhir-net-api that will display the same results has org.hl7.fhir.validator.jar?
string HL7FilePath = string.Format("{0}\\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);
FHIR Validator Build ??
Arguments: C:\HL7Tools\validator\REC78_1.xml -version 3.0
.. connect to tx server # http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:\HL7Tools\validator\Sample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(#"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.

Resources