@medplum/fhir-router 2.0.22 → 2.0.23
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/dist/cjs/index.cjs +372 -369
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.min.mjs.map +1 -1
- package/dist/esm/index.mjs +373 -370
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/{graphql.d.ts → graphql/graphql.d.ts} +2 -2
- package/dist/types/graphql/index.d.ts +1 -0
- package/dist/types/graphql/input-types.d.ts +2 -0
- package/dist/types/graphql/output-types.d.ts +4 -0
- package/dist/types/graphql/utils.d.ts +46 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { FhirRequest, FhirResponse, FhirRouter } from '
|
|
3
|
-
import { FhirRepository } from '
|
|
2
|
+
import { FhirRequest, FhirResponse, FhirRouter } from '../fhirrouter';
|
|
3
|
+
import { FhirRepository } from '../repo';
|
|
4
4
|
/**
|
|
5
5
|
* Handles FHIR GraphQL requests.
|
|
6
6
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './graphql';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GraphQLOutputType } from 'graphql';
|
|
2
|
+
export declare const outputTypeCache: Record<string, GraphQLOutputType | undefined>;
|
|
3
|
+
export declare function getGraphQLOutputType(inputType: string): GraphQLOutputType;
|
|
4
|
+
export declare function buildGraphQLOutputType(resourceType: string): GraphQLOutputType;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLFieldConfigArgumentMap, GraphQLResolveInfo, GraphQLScalarType } from 'graphql';
|
|
2
|
+
import { FhirRepository } from '../repo';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
import { OperationOutcome, Reference, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
5
|
+
import { SearchRequest } from '@medplum/core';
|
|
6
|
+
export interface GraphQLContext {
|
|
7
|
+
repo: FhirRepository;
|
|
8
|
+
dataLoader: DataLoader<Reference, Resource>;
|
|
9
|
+
}
|
|
10
|
+
export declare const typeCache: Record<string, GraphQLScalarType | undefined>;
|
|
11
|
+
export declare function parseSearchArgs(resourceType: ResourceType, source: any, args: Record<string, string>): SearchRequest;
|
|
12
|
+
export declare function graphQLFieldToFhirParam(code: string): string;
|
|
13
|
+
export declare function fhirParamToGraphQLField(code: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* GraphQL data loader for search requests.
|
|
16
|
+
* The field name should always end with "List" (i.e., "Patient" search uses "PatientList").
|
|
17
|
+
* The search args should be FHIR search parameters.
|
|
18
|
+
* @param source The source/root. This should always be null for our top level readers.
|
|
19
|
+
* @param args The GraphQL search arguments.
|
|
20
|
+
* @param ctx The GraphQL context.
|
|
21
|
+
* @param info The GraphQL resolve info. This includes the schema, and additional field details.
|
|
22
|
+
* @returns Promise to read the resoures for the query.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveBySearch(source: any, args: Record<string, string>, ctx: GraphQLContext, info: GraphQLResolveInfo): Promise<Resource[] | undefined>;
|
|
25
|
+
export declare function buildSearchArgs(resourceType: string): GraphQLFieldConfigArgumentMap;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the depth of the GraphQL node in a query.
|
|
28
|
+
* We use "selections" as the representation of depth.
|
|
29
|
+
* As a rough approximation, it's the number of indentations in a well formatted query.
|
|
30
|
+
* @param path The GraphQL node path.
|
|
31
|
+
* @returns The "depth" of the node.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDepth(path: ReadonlyArray<string | number>): number;
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if the field is requested in the GraphQL query.
|
|
36
|
+
* @param info The GraphQL resolve info. This includes the field name.
|
|
37
|
+
* @param fieldName The field name to check.
|
|
38
|
+
* @returns True if the field is requested in the GraphQL query.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isFieldRequested(info: GraphQLResolveInfo, fieldName: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an OperationOutcome for GraphQL errors.
|
|
43
|
+
* @param errors Array of GraphQL errors.
|
|
44
|
+
* @returns OperationOutcome with the GraphQL errors as OperationOutcome issues.
|
|
45
|
+
*/
|
|
46
|
+
export declare function invalidRequest(errors: ReadonlyArray<GraphQLError>): OperationOutcome;
|