Despite the search of different issues about this, the bug seems to still keep on existing.
I tried to create a couple of graphQL endpoints, to split admin and "public" resolvers.
In my app.module.ts
ProfileModule,
AdminProfileModule,
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
debug: config.isDev(),
playground: true,
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
context: ({ req }) => ({ req }),
transformAutoSchemaFile: true,
include: [
ProfileModule,
],
}),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
debug: config.isDev(),
playground: true,
autoSchemaFile: join(process.cwd(), 'src/admin.gql'),
context: ({ req }) => ({ req }),
transformAutoSchemaFile: true,
include: [
AdminProfileModule,
],
}),
While trying to debug I noticed that just the fact to add a GraphQLModule.forRoot, even with an empty includes array, even when not injecting AdminProfileModule, generated the following error :
Schema must contain uniquely named types but contains multiple types named Links
ProfileModule and AdminProfileModule share some schemas, but two resolvers are different but with queries handling same name. For design reasons, I don't wanna change the names.
I think the bug is due to the fact that GraphQL.forRoot doesn't dive into "includes" modules, but check out for all imported modules.
Could you check it out??
Thanks.
Related
I'm trying to build a website builder within the drag-and-drop abilities via using Vue3. So, the user will be playing with the canvas and generate a config structure that going to post the backend. Furthermore, the server-side will generate static HTML according to this config.
Eventually, the config will be like the below and it works perfectly. The config only can have HTML tags and attributes currently. Backend uses h() function to generate dom tree.
My question is: can I use .vue component that will generate on the server side as well? For example, the client-side has a Container.vue file that includes some interactions, styles, etc. How can the backend recognize/resolve this vue file?
UPDATE:
Basically, I want to use the Vue component that exists on the Client side on the backend side to generate HTML strings same as exactly client side. (including styles, interactions etc).
Currently, I'm able to generate HTML string via the below config but want to extend/support Vue component itself.
Note: client and server are completely different projects. Currently, server takes config and runs createSSRApp, renderToString methods.
Here is the gist of how server would handle the API:
https://gist.github.com/yulafezmesi/162eafcf7f0dcb3cb83fb822568a6126
{
id: "1",
tagName: "main",
root: true,
type: "container",
properties: {
class: "h-full",
style: {
width: "800px",
transform: "translateZ(0)",
},
},
children: [
{
id: "9",
type: "image",
tagName: "figure",
interactive: true,
properties: {
class: "absolute w-28",
style: {
translate: "63px 132px",
},
},
},
],
}
This might get you started: https://vuejs.org/guide/scaling-up/ssr.html#rendering-an-app
From the docs:
// this runs in Node.js on the server.
import { createSSRApp } from 'vue'
// Vue's server-rendering API is exposed under `vue/server-renderer`.
import { renderToString } from 'vue/server-renderer'
const app = createSSRApp({
data: () => ({ count: 1 }),
template: `<button #click="count++">{{ count }}</button>`
})
renderToString(app).then((html) => {
console.log(html)
})
I guess extract the template from request or by reading the submitted Vue file and use that as the template parameter value
I had problems yesterday that I never had on previous nuxt projects about CORS.
I have indeed read that it was necessary to set the proxy to solve the problem. Despite this, I have a 504 error. I followed several solutions found on the github repository & stack overflow without having found the problem.
My post function
await this.$axios.post("/api/contact", {
replyTo: this.form.email,
name: this.form.name,
firstName: this.form.firstName,
phone: this.form.phone,
company: "",
message: this.form.message,}).then(() => {this.isSend = true;}).catch((e) => {console.log(e);this.isError = true;});
my nuxt config
modules: ["#nuxtjs/axios", "#nuxtjs/proxy"],
axios: {
proxy: true,
debug: true,
},
proxy: {
"/api/": {
target: "http://myserver.eu-west-3.elasticbeanstalk.com/",
pathRewrite: { "^/api/": "" },
changeOrigin: true,
},
},
my api call need to be done on http://myserver.eu-west-3.elasticbeanstalk.com/contact
I'm pretty sure I made a mistake somewhere, but I really can't find where...
error504
Initial cors error
EDIT 1 : everything work find with postman, but not with my frontend i tried with a apigateway lambda ses, it's work with postman, not with front end, i tried with a node express server with ses, it's work with lambda, not with front end :(
EDIT 2 : I managed to make the form submission work, I cloned one of my old projects, then I replaced the content with that of this project. I think it's a nuxtJs and Axios problem. Very strange.
I inherited a project, where the original owner uses global variables. The app was made in class-based components, but I have since been using functional components. I much prefer functional components in React-Native.
Anyways, the original user has an API route defined in the global variable. The data structure looks like this, and it is called/instantiated in the constructor of App.js, which is the root of our project:
initGlobalState = async () => {
this.setGlobal({
token: '',
API_ROUTE: API_ROUTE.TEST_API_URL, // TODO
selectedAppId: "1",
maps: [],
assets: [],
places: [],
isLoggedIn: false,
sliderValue: 0,
isSwitchOn: false,
pw: "",
ssid: "",
gatewaySelected: false,
configSelected: "",
envCollection: [],
})
};
Now, when we make API calls, we just reference this.global.API_ROUTE from anywhere in the project, and it returns the value that was set in the above setGlobal. What's confusing is, setGlobal is not defined anywhere...so it must be an installed package that uses it somehow?
When I try to do the same in a functional component, this.global is not recognized in general. Regular global is not even recognized. I am unsure how I would access the global variable in this case, any ideas or thoughts to walk thru this?
I am trying to integrate Mollie payments into my NestJS backend.
To make a connection with Mollie, I have to use their MollieClient function. However, when I try to use it in a service I get the error:
Nest can't resolve dependencies of the NewUserService (UserService, MailService, ConfigService, JwtService, ?). Please make sure that the argument Object at index [4] is available in the NewUserModule context.
I am pretty sure this means I have to add a Mollie module/service to the NewUserModule, but I think the package doesn't actually come with a module made for NestJS. So if I try to make a Mollie module/service or use the MollieClient in another service, it asks me to provide it whilst I don't have anything to provide.
I'm pretty new to NestJS and backend development in general, so am I mistaken? Or is there a module added in the installed package?
If there isn't a module, should I make one? What exactly should be in such a module? Is there some sort of guide for it?
I realise this might be a rather vague series of questions, but I'm not very sure how to approach this.
Edit:
Rewrote the question for clarification.
Thanks in advance!
The message means, that Nest does not now how to resolve the 5th constructor argument of your NewUserService. I assume this is something like a MollieService?
You need to add MollieService as Provider to your NewUserModule:
#Module({
imports: [...],
controllers: [...],
providers: [
...otherProviders,
MollieService
]
})
export class NewUserModule {}
Or you can create a separate MollieModule and import it in NewUserModule:
#Module({
providers: [ MollieService ],
exports: [ MollieService ] // export MollieService, so that other modules can use it
})
export class MollieModule {}
#Module({
imports: [MollieModule],
controllers: [...],
providers: [...] // no need to provide MollieService here, because it's imported from MollieModule
})
export class NewUserModule {}
Of course you must also implement the MollieService using their SDK.
A recommend to read the Documentation on Modules. They are a little hard to understand at a first sight, but a powerful concept!
EDIT:
I would suggest to wrap the MollySDK in a service. This way you're not dealing with molly at various places in your app and prevent leaking it's api and types into your services.
#Injectable()
export class MollyService {
private readonly mollyClient: WhateverType;
constructor() {
this.mollyClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });
}
createPayment() {
this.mollieClient.payments.create({...});
}
}
This service could be injected as usual.
However if you really want to use the molly-client directly, you have to use a custom provider
#Module({
providers: [{
provides: 'MOLLY_CLIENT',
useFactory: () => createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' }) // you could also use useValue instead of useFactory
}],
exports: [ 'MOLLY_CLIENT' ]
})
export class MollieModule {}
Then inject it into NewUsersService like so:
constructor(#Inject('MOLLY_CLIENT')private readonly mollyClient: WhateverType) {}
I can't seem to figure out how to include multiple models.
I have three models.
Tabs, Servers, and Points
Tabs hasMany Server
Servers belongsTo Tabs and hasMany Points
Points belongTo Server
In my routes I am doing this:
router.get('/', function (req, res, next) {
models.TabConfig.findAll({
include: [models.ServerConfig]
}).then(function (tabs) {
res.render('index', {
tabs: tabs,
});
});
});
module.exports = router;
which gets me all the tabs, and the servers associated with them. Works great.
But I want the points associated with the Servers as well so I can iterate over the tabs, servers, and points.
Any ideas?
Thanks
At first glance, you can use eager loading with multiple models:
models.TabConfig.findAll({
include: [{
model: models.ServerConfig,
include: [models.Points]
}]
})
That should give you an array with all the Tabs and its Servers, and inside each Server you will have its points associated to it.
[{
some: 'tab',
saved: 'property',
Servers: [{
some: 'server',
saved: 'property',
Points: [...]
}, ...]
}, ...]