Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getSchema(endpoint) {
// you can't use relative URLs within Netlify Functions so need a base URL
// process.env.URL is one of many build env variables:
// https://www.netlify.com/docs/continuous-deployment/#build-environment-variables
// Netlify Dev only supports URL and DEPLOY URL for now
const uri = process.env.URL + "/.netlify/functions/" + endpoint;
const link = createHttpLink({ uri, fetch });
const schema = await introspectSchema(link);
const executableSchema = makeRemoteExecutableSchema({ schema, link });
return executableSchema;
}
const getRemoteSchema = async (uri, headers, linkOverRide = null) => {
const link = makeHttpAndWsLink(uri, headers);
if (linkOverRide) {
return makeRemoteExecutableSchema({
schema: await introspectSchema(linkOverRide),
link,
});
}
return makeRemoteExecutableSchema({
schema: await introspectSchema(link),
link,
});
};
export async function createRemoteSchema({ broker, service }: RemoteSchemaOptions) {
const link = new MoleculerLink({ broker, service: service.name });
const schema = await introspectSchema(link);
return makeRemoteExecutableSchema({ schema, link });
}
const createMovieServiceSchema = async () => {
const schema = await introspectSchema(movieServiceLink);
return makeRemoteExecutableSchema({
schema,
link: movieServiceLink
});
};
private async getApiSchema(apiLink: string): Promise {
try {
const httpLink = new HttpLink({
uri: apiLink,
fetch,
});
const retryLink = this.retryLink().concat(httpLink);
const link = this.contextLink().concat(retryLink);
const coreIntrospect = await introspectSchema(link);
return makeRemoteExecutableSchema({
schema: coreIntrospect,
link,
});
} catch (error) {
this.logger.error(error);
return null;
}
}
export default async () => {
const link = new HttpLink({ uri: userUrl, fetch });
const schema = await introspectSchema(link);
return makeRemoteExecutableSchema({
schema,
link,
});
};
async getRemoteExecutableSchema(uri, token) {
const http = new HttpLink({ uri, fetch })
const link = setContext(() => ({
headers: {
Authorization: `bearer ${token}`,
},
})).concat(http)
const remoteSchema = await introspectSchema(link)
return makeRemoteExecutableSchema({
schema: remoteSchema,
link,
})
}