prisma-client-lib
Advanced tools
Comparing version 1.20.0-alpha.33 to 1.20.0-alpha.36
@@ -19,2 +19,3 @@ import { ClientOptions } from './types'; | ||
$subscribe: any; | ||
$graphql: any; | ||
$exists: any; | ||
@@ -46,3 +47,4 @@ debug: any; | ||
getDeepType(type: any): any; | ||
private buildGraphQL; | ||
private buildExists; | ||
} |
@@ -178,2 +178,3 @@ "use strict"; | ||
var token = secret ? jsonwebtoken_1.sign({}, secret) : undefined; | ||
this.$graphql = this.buildGraphQL(); | ||
this.$exists = this.buildExists(); | ||
@@ -385,3 +386,3 @@ this.token = token; | ||
} | ||
else if (name === 'Query') { | ||
else if (name === 'Query' || name === 'Subscription') { | ||
if (field.args.length === 1) { | ||
@@ -432,2 +433,8 @@ realArgs = { where: realArgs }; | ||
}; | ||
Client.prototype.buildGraphQL = function () { | ||
var _this = this; | ||
return function (query, variables) { | ||
return _this.client.request(query, variables); | ||
}; | ||
}; | ||
Client.prototype.buildExists = function () { | ||
@@ -434,0 +441,0 @@ var _this = this; |
@@ -15,3 +15,3 @@ import { TypescriptGenerator } from './typescript-client'; | ||
renderClientConstructor(): string; | ||
format(code: string, options?: prettier.Options): any; | ||
format(code: string, options?: prettier.Options): string; | ||
renderAtLeastOne(): string; | ||
@@ -18,0 +18,0 @@ renderGraphQL(): string; |
@@ -70,3 +70,4 @@ import { Generator } from './Generator'; | ||
printEndpoint(options: RenderOptions): string; | ||
printSecret(options: RenderOptions): string | null; | ||
render(options: RenderOptions): string; | ||
} |
@@ -375,2 +375,21 @@ "use strict"; | ||
}; | ||
GoGenerator.prototype.printSecret = function (options) { | ||
if (!options.secret) { | ||
return "\"\""; | ||
} | ||
else { | ||
if (options.secret.startsWith('${process.env')) { | ||
// Find a better way to generate Go env construct | ||
var envVariable = ("" + options.secret | ||
.replace('${process.env[', '') | ||
.replace(']}', '')) | ||
.replace("'", '') | ||
.replace("'", ''); | ||
return "os.Getenv(\"" + envVariable + "\")"; | ||
} | ||
else { | ||
return "\"" + options.secret.replace("'", '').replace("'", '') + "\""; | ||
} | ||
} | ||
}; | ||
GoGenerator.prototype.render = function (options) { | ||
@@ -387,5 +406,5 @@ var _this = this; | ||
// to which generated code gets appened. | ||
var fixed = "\n // Code generated by Prisma CLI (https://github.com/prisma/prisma). DO NOT EDIT.\n\npackage prisma\n\nimport (\n\t\"context\"\n\t\"errors\"\n\n\t\"github.com/prisma/prisma-client-lib-go\"\n\n\t\"github.com/machinebox/graphql\"\n)\n\nvar ErrNoResult = errors.New(\"query returned no result\")\n\nfunc Str(v string) *string { return &v }\nfunc Int32(v int32) *int32 { return &v }\nfunc Bool(v bool) *bool { return &v }\n\ntype BatchPayloadExec struct {\n\texec *prisma.BatchPayloadExec\n}\n\nfunc (exec *BatchPayloadExec) Exec(ctx context.Context) (BatchPayload, error) {\n\tbp, err := exec.exec.Exec(ctx)\n return BatchPayload(bp), err\n}\n\ntype BatchPayload struct {\n\tCount int64 `json:\"count\"`\n}\n\ntype Aggregate struct {\n\tCount int64 `json:\"count\"`\n}\n\ntype Client struct {\n\tClient *prisma.Client\n}\n\ntype Options struct {\n\tEndpoint string\n}\n\nfunc New(options *Options, opts ...graphql.ClientOption) *Client {\n\tendpoint := DefaultEndpoint\n\tif options != nil {\n\t\tendpoint = options.Endpoint\n\t}\n\treturn &Client{\n\t\tClient: prisma.New(endpoint, opts...),\n\t}\n}\n\nfunc (client *Client) GraphQL(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error) {\n\treturn client.Client.GraphQL(ctx, query, variables)\n}\n"; | ||
var fixed = "\n // Code generated by Prisma CLI (https://github.com/prisma/prisma). DO NOT EDIT.\n\npackage prisma\n\nimport (\n\t\"context\"\n \"errors\"\n \"os\"\n\n\t\"github.com/prisma/prisma-client-lib-go\"\n\n\t\"github.com/machinebox/graphql\"\n)\n\nvar ErrNoResult = errors.New(\"query returned no result\")\n\nfunc Str(v string) *string { return &v }\nfunc Int32(v int32) *int32 { return &v }\nfunc Bool(v bool) *bool { return &v }\n\ntype BatchPayloadExec struct {\n\texec *prisma.BatchPayloadExec\n}\n\nfunc (exec *BatchPayloadExec) Exec(ctx context.Context) (BatchPayload, error) {\n\tbp, err := exec.exec.Exec(ctx)\n return BatchPayload(bp), err\n}\n\ntype BatchPayload struct {\n\tCount int64 `json:\"count\"`\n}\n\ntype Aggregate struct {\n\tCount int64 `json:\"count\"`\n}\n\ntype Client struct {\n\tClient *prisma.Client\n}\n\ntype Options struct {\n Endpoint string\n Secret string\n}\n\nfunc New(options *Options, opts ...graphql.ClientOption) *Client {\n endpoint := DefaultEndpoint\n secret := Secret\n\tif options != nil {\n endpoint = options.Endpoint\n secret = options.Secret\n\t}\n\treturn &Client{\n\t\tClient: prisma.New(endpoint, secret, opts...),\n\t}\n}\n\nfunc (client *Client) GraphQL(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error) {\n\treturn client.Client.GraphQL(ctx, query, variables)\n}\n"; | ||
// Dynamic contains the parts of the generated code that are dynamically generated. | ||
var dynamic = "\n\nvar DefaultEndpoint = " + this.printEndpoint(options) + "\n\n" + this.printOperation(queryFields, 'query', options) + "\n\n" + this.printOperation(mutationFields, 'mutation', options) + "\n\n" + typeNames | ||
var dynamic = "\n\nvar DefaultEndpoint = " + this.printEndpoint(options) + "\nvar Secret = " + this.printSecret(options) + "\n\n" + this.printOperation(queryFields, 'query', options) + "\n\n" + this.printOperation(mutationFields, 'mutation', options) + "\n\n" + typeNames | ||
.map(function (key) { | ||
@@ -392,0 +411,0 @@ var type = typeMap[key]; |
@@ -5,4 +5,4 @@ import { TypescriptGenerator, RenderOptions } from './typescript-client'; | ||
constructor(options: any); | ||
format(code: string, options?: prettier.Options): any; | ||
renderJavascript(options?: RenderOptions): any; | ||
format(code: string, options?: prettier.Options): string; | ||
renderJavascript(options?: RenderOptions): string; | ||
} |
@@ -36,5 +36,5 @@ import { GraphQLObjectType, GraphQLSchema, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLInputField, GraphQLField, GraphQLInputType, GraphQLOutputType, GraphQLScalarType, GraphQLEnumType, GraphQLFieldMap, GraphQLObjectType as GraphQLObjectTypeRef } from 'graphql'; | ||
}); | ||
format(code: string, options?: prettier.Options): any; | ||
format(code: string, options?: prettier.Options): string; | ||
renderAtLeastOne(): string; | ||
render(options?: RenderOptions): any; | ||
render(options?: RenderOptions): string; | ||
renderClientConstructor(): string; | ||
@@ -41,0 +41,0 @@ renderImports(): string; |
{ | ||
"name": "prisma-client-lib", | ||
"version": "1.20.0-alpha.33", | ||
"version": "1.20.0-alpha.36", | ||
"author": "Tim Suchanek <suchanek@prisma.io>", | ||
@@ -23,23 +23,23 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@types/node": "^10.9.4", | ||
"debug": "^4.0.1", | ||
"graphql-tag": "^2.9.2", | ||
"@types/node": "^10.12.0", | ||
"@types/prettier": "^1.13.2", | ||
"debug": "^4.1.0", | ||
"graphql-tag": "^2.10.0", | ||
"http-link-dataloader": "^0.1.4", | ||
"jsonwebtoken": "^8.3.0", | ||
"lodash.flatten": "^4.4.0", | ||
"prettier": "^1.14.2", | ||
"subscriptions-transport-ws": "^0.9.14", | ||
"prettier": "^1.14.3", | ||
"subscriptions-transport-ws": "^0.9.15", | ||
"uppercamelcase": "^3.0.0", | ||
"ws": "^6.0.0", | ||
"zen-observable": "^0.8.9" | ||
"ws": "^6.1.0", | ||
"zen-observable": "^0.8.10" | ||
}, | ||
"devDependencies": { | ||
"@types/graphql": "0.13", | ||
"@types/node": "10.0.2", | ||
"@types/graphql": "14.0.3", | ||
"ava": "^0.25.0", | ||
"graphql": "^14.0.2", | ||
"semantic-release": "^15.9.15", | ||
"semantic-release": "^15.10.4", | ||
"tslint": "5.11.0", | ||
"tslint-config-standard": "8.0.1", | ||
"typescript": "3.0.3" | ||
"typescript": "3.1.3" | ||
}, | ||
@@ -46,0 +46,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
192682
7
2457
13
+ Added@types/prettier@^1.13.2
+ Added@types/prettier@1.19.1(transitive)
Updated@types/node@^10.12.0
Updateddebug@^4.1.0
Updatedgraphql-tag@^2.10.0
Updatedprettier@^1.14.3
Updatedws@^6.1.0
Updatedzen-observable@^0.8.10