runlify 0.0.100 → 0.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/projectsGeneration/generators/fileTemplates/ui/environment/src/dataProvider/index.js
CHANGED
|
@@ -7,11 +7,11 @@ var utils_1 = require("../../../../../../utils");
|
|
|
7
7
|
var metaUtils_1 = require("../../../../../../metaUtils");
|
|
8
8
|
var uiDataProviderTmpl = function (entities, options) {
|
|
9
9
|
if (options === void 0) { options = types_1.defaultBootstrapEntityOptions; }
|
|
10
|
-
return "import buildGraphQLProvider, {buildQuery as buildQueryFactory} from 'ra-data-graphql-simple';\nimport {IntrospectionResult} from 'ra-data-graphql';\nimport {DELETE} from 'ra-core';\nimport gql from 'graphql-tag';\nimport {IntrospectionType, IntrospectionSchema} from 'graphql';\nimport {mapping} from '../adm/entityMapping';\nimport sch from '../generated/graphql.schema.json';\nimport {ApolloClient} from '@apollo/client';\n".concat(options.skipWarningThisIsGenerated
|
|
10
|
+
return "import buildGraphQLProvider, {buildQuery as buildQueryFactory} from 'ra-data-graphql-simple';\nimport {IntrospectionResult} from 'ra-data-graphql';\nimport {DELETE} from 'ra-core';\nimport gql from 'graphql-tag';\nimport {IntrospectionType, IntrospectionSchema} from 'graphql';\nimport {mapping} from '../adm/entityMapping';\nimport sch from '../generated/graphql.schema.json';\nimport {ApolloClient} from '@apollo/client';\nimport getCustomMethods from './getCustomMethods';\n".concat(options.skipWarningThisIsGenerated
|
|
11
11
|
? ''
|
|
12
12
|
: "\n// ".concat(utils_1.generatedWarning, "\n"), "\nconst schema = sch.__schema;\n\nconst getGqlResource = (resource: string) => {\n if (resource in mapping) {\n return mapping[resource as keyof typeof mapping];\n } else {\n throw new Error(`Unknown resource ${resource}`);\n }\n};\n\nconst numberIdResources: string[] = [\n ").concat(entities
|
|
13
13
|
.filter(function (m) { return (0, metaUtils_1.getKeyField)(m).type === 'bigint' || (0, metaUtils_1.getKeyField)(m).type === 'int'; })
|
|
14
|
-
.map(function (m) { return "'".concat((0, cases_1.camel)(m.name), "',"); }).join("\n "), "\n];\n\nconst customBuildQuery = (introspection: IntrospectionResult) =>\n (fetchType: string, originalResource: string, params: any) => {\n const resource = getGqlResource(originalResource);\n\n const builtQuery = buildQueryFactory(introspection)(fetchType, resource, params);\n\n if (numberIdResources.includes(resource) && fetchType === 'GET_ONE' && 'id' in params) {\n params.id = Number.parseInt(params.id, 10);\n }\n\n if (resource === 'Command' && fetchType === 'GET_ONE') {\n return {\n // Use the default query variables and parseResponse\n ...builtQuery,\n\n // Override the query\n query: gql`\n query Command($id: ID!) {\n data: Command(id: $id) {\n id\n reference\n customer {\n id\n firstName\n lastName\n }\n }\n }\n `,\n };\n }\n\n return builtQuery;\n };\n\nexport default (client: ApolloClient<unknown>) => buildGraphQLProvider({\n
|
|
14
|
+
.map(function (m) { return "'".concat((0, cases_1.camel)(m.name), "',"); }).join("\n "), "\n];\n\nconst customBuildQuery = (introspection: IntrospectionResult) =>\n (fetchType: string, originalResource: string, params: any) => {\n const resource = getGqlResource(originalResource);\n\n const builtQuery = buildQueryFactory(introspection)(fetchType, resource, params);\n\n if (numberIdResources.includes(resource) && fetchType === 'GET_ONE' && 'id' in params) {\n params.id = Number.parseInt(params.id, 10);\n }\n\n if (resource === 'Command' && fetchType === 'GET_ONE') {\n return {\n // Use the default query variables and parseResponse\n ...builtQuery,\n\n // Override the query\n query: gql`\n query Command($id: ID!) {\n data: Command(id: $id) {\n id\n reference\n customer {\n id\n firstName\n lastName\n }\n }\n }\n `,\n };\n }\n\n return builtQuery;\n };\n\nexport default async (client: ApolloClient<unknown>) => {\n const baseDataProvider = await buildGraphQLProvider({\n buildQuery: customBuildQuery,\n client: client as any,\n introspection: {\n schema: schema as unknown as IntrospectionSchema,\n operationNames: {\n [DELETE]: (resource: IntrospectionType) =>\n `remove${resource.name}`,\n },\n },\n });\n\n return {\n ...baseDataProvider,\n ...getCustomMethods(client, baseDataProvider),\n };\n};\n");
|
|
15
15
|
};
|
|
16
16
|
exports.uiDataProviderTmpl = uiDataProviderTmpl;
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvcHJvamVjdHNHZW5lcmF0aW9uL2dlbmVyYXRvcnMvZmlsZVRlbXBsYXRlcy91aS9lbnZpcm9ubWVudC9zcmMvZGF0YVByb3ZpZGVyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDBEQUF3RDtBQUN4RCxpREFHZ0M7QUFFaEMsaURBQTBEO0FBQzFELHlEQUF5RDtBQUVsRCxJQUFNLGtCQUFrQixHQUFHLFVBQ2hDLFFBQWtCLEVBQ2xCLE9BQStEO0lBQS9ELHdCQUFBLEVBQUEsVUFBa0MscUNBQTZCO0lBQzVELE9BQUEsdWVBVUgsT0FBTyxDQUFDLDBCQUEwQjtRQUNoQyxDQUFDLENBQUMsRUFBRTtRQUNKLENBQUMsQ0FBQyxlQUNELHdCQUFnQixPQUNwQiwwU0FhRyxRQUFRO1NBQ1AsTUFBTSxDQUNMLFVBQUMsQ0FBQyxJQUFLLE9BQUEsSUFBQSx1QkFBVyxFQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksS0FBSyxRQUFRLElBQUksSUFBQSx1QkFBVyxFQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksS0FBSyxLQUFLLEVBQWpFLENBQWlFLENBQ3pFO1NBQ0EsR0FBRyxDQUFDLFVBQUMsQ0FBQyxJQUFLLE9BQUEsV0FBSSxJQUFBLGFBQUssRUFBQyxDQUFDLENBQUMsSUFBSSxDQUFDLE9BQUksRUFBckIsQ0FBcUIsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUN6QyxDQUFDLHEvQ0F3REg7QUF4RkksQ0F3RkosQ0FBQTtBQTNGWSxRQUFBLGtCQUFrQixzQkEyRjlCIn0=
|