How to use the graphql.GraphQLUnionType function in graphql

To help you get started, we’ve selected a few graphql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Asymmetrik / graphql-fhir / src / resources / 1_0_2 / schemas / episodeofcarecareteam.schema.js View on Github external
description:
				'May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.',
		},
		// valueSetReference: http://hl7.org/fhir/ValueSet/participant-role
		role: {
			type: new GraphQLList(require('./codeableconcept.schema.js')),
			description:
				'The role this team member is taking within this episode of care.',
		},
		period: {
			type: require('./period.schema.js'),
			description:
				'The period of time this practitioner is performing some role within the episode of care.',
		},
		member: {
			type: new GraphQLUnionType({
				name: 'EpisodeOfCarecareTeammember_member_Union',
				description: 'The practitioner (or Organization) within the team.',
				types: () => [
					require('./practitioner.schema.js'),
					require('./organization.schema.js'),
				],
				resolveType(data) {
					if (data && data.resourceType === 'Practitioner') {
						return require('./practitioner.schema.js');
					}
					if (data && data.resourceType === 'Organization') {
						return require('./organization.schema.js');
					}
				},
			}),
			description: 'The practitioner (or Organization) within the team.',
github Asymmetrik / graphql-fhir / src / resources / 3_0_1 / schemas / imagingstudy.schema.js View on Github external
type: new GraphQLNonNull(
				new GraphQLUnionType({
					name: 'ImagingStudypatient_patient_Union',
					description: 'The patient imaged in the study.',
					types: () => [require('./patient.schema.js')],
					resolveType(data) {
						if (data && data.resourceType === 'Patient') {
							return require('./patient.schema.js');
						}
					},
				}),
			),
			description: 'The patient imaged in the study.',
		},
		context: {
			type: new GraphQLUnionType({
				name: 'ImagingStudycontext_context_Union',
				description:
					'The encounter or episode at which the request is initiated.',
				types: () => [
					require('./encounter.schema.js'),
					require('./episodeofcare.schema.js'),
				],
				resolveType(data) {
					if (data && data.resourceType === 'Encounter') {
						return require('./encounter.schema.js');
					}
					if (data && data.resourceType === 'EpisodeOfCare') {
						return require('./episodeofcare.schema.js');
					}
				},
			}),
github Asymmetrik / graphql-fhir / src / resources / 3_0_1 / schemas / diagnosticreport.schema.js View on Github external
if (data && data.resourceType === 'Group') {
						return require('./group.schema.js');
					}
					if (data && data.resourceType === 'Device') {
						return require('./device.schema.js');
					}
					if (data && data.resourceType === 'Location') {
						return require('./location.schema.js');
					}
				},
			}),
			description:
				'The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.',
		},
		context: {
			type: new GraphQLUnionType({
				name: 'DiagnosticReportcontext_context_Union',
				description:
					'The healthcare event  (e.g. a patient and healthcare provider interaction) which this DiagnosticReport per is about.',
				types: () => [
					require('./encounter.schema.js'),
					require('./episodeofcare.schema.js'),
				],
				resolveType(data) {
					if (data && data.resourceType === 'Encounter') {
						return require('./encounter.schema.js');
					}
					if (data && data.resourceType === 'EpisodeOfCare') {
						return require('./episodeofcare.schema.js');
					}
				},
			}),
github Asymmetrik / graphql-fhir / src / resources / 3_0_1 / schemas / communication.schema.js View on Github external
name: 'Communicationtopic_topic_Union',
					description:
						'The resources which were responsible for or related to producing this communication.',
					types: () => [require('./resource.schema.js')],
					resolveType(data) {
						if (data && data.resourceType === 'Resource') {
							return require('./resource.schema.js');
						}
					},
				}),
			),
			description:
				'The resources which were responsible for or related to producing this communication.',
		},
		context: {
			type: new GraphQLUnionType({
				name: 'Communicationcontext_context_Union',
				description: 'The encounter within which the communication was sent.',
				types: () => [
					require('./encounter.schema.js'),
					require('./episodeofcare.schema.js'),
				],
				resolveType(data) {
					if (data && data.resourceType === 'Encounter') {
						return require('./encounter.schema.js');
					}
					if (data && data.resourceType === 'EpisodeOfCare') {
						return require('./episodeofcare.schema.js');
					}
				},
			}),
			description: 'The encounter within which the communication was sent.',
github brabeji / swagger-graphql-schema / lib / index.js View on Github external
(0, _traverse2.default)(rootSchema).forEach(function parseUnion(schema, context) {
		var isUnion = schema && (0, _lodash.isArray)(schema.anyOf);
		var isCached = schema && schema.$$type;
		if (isUnion && !isCached) {
			var schemaId = Symbol(TYPE_SCHEMA_SYMBOL_LABEL);
			schema.$$type = schemaId;
			typesCache[schemaId] = new _graphql.GraphQLUnionType({
				name: extractTypeName(context),
				types: function types() {
					return schema.anyOf.map(function (subSchema) {
						return typesCache[subSchema.$$type];
					});
				},
				resolveType: function resolveType(value) {
					if (value[discriminatorFieldName]) {
						return value[discriminatorFieldName];
					}
				}
			});
		}
	});
};
github Asymmetrik / graphql-fhir / src / resources / 3_0_1 / schemas / deviceusestatement.schema.js View on Github external
if (data && data.resourceType === 'Patient') {
						return require('./patient.schema.js');
					}
					if (data && data.resourceType === 'Practitioner') {
						return require('./practitioner.schema.js');
					}
					if (data && data.resourceType === 'RelatedPerson') {
						return require('./relatedperson.schema.js');
					}
				},
			}),
			description: 'Who reported the device was being used by the patient.',
		},
		device: {
			type: new GraphQLNonNull(
				new GraphQLUnionType({
					name: 'DeviceUseStatementdevice_device_Union',
					description: 'The details of the device used.',
					types: () => [require('./device.schema.js')],
					resolveType(data) {
						if (data && data.resourceType === 'Device') {
							return require('./device.schema.js');
						}
					},
				}),
			),
			description: 'The details of the device used.',
		},
		indication: {
			type: new GraphQLList(require('./codeableconcept.schema.js')),
			description: 'Reason or justification for the use of the device.',
		},
github Asymmetrik / graphql-fhir / src / resources / 3_0_1 / schemas / supplyrequestrequester.schema.js View on Github external
description:
				'unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.',
		},
		extension: {
			type: new GraphQLList(require('./extension.schema.js')),
			description:
				'May be used to represent additional information that is not part of the basic definition of the element. In order to make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.',
		},
		modifierExtension: {
			type: new GraphQLList(require('./extension.schema.js')),
			description:
				'May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.',
		},
		agent: {
			type: new GraphQLNonNull(
				new GraphQLUnionType({
					name: 'SupplyRequestrequesteragent_agent_Union',
					description:
						'The device, practitioner, etc. who initiated the request.',
					types: () => [
						require('./practitioner.schema.js'),
						require('./organization.schema.js'),
						require('./patient.schema.js'),
						require('./relatedperson.schema.js'),
						require('./device.schema.js'),
					],
					resolveType(data) {
						if (data && data.resourceType === 'Practitioner') {
							return require('./practitioner.schema.js');
						}
						if (data && data.resourceType === 'Organization') {
							return require('./organization.schema.js');
github artsy / metaphysics / src / schema / v2 / artwork / highlight.ts View on Github external
import { ShowType } from "schema/v2/show"
import { ArticleType } from "schema/v2/article"
import { GraphQLUnionType } from "graphql"

export const ArtworkHighlightType = new GraphQLUnionType({
  name: "ArtworkHighlight",
  types: [ShowType, ArticleType],
  resolveType(value, _context, _info) {
    switch (value.highlight_type) {
      case "Show":
        return ShowType
      case "Sale":
      case "Article":
        return ArticleType
      default:
        throw new Error(`Unknown highlight type: ${value.highlight_type}`)
    }
  },
})
github zth / graphql-client-example-server / src / graphqlTypes.ts View on Github external
type: new GraphQLList(userType),
      resolve(obj, args) {
        return paginate(
          args.offset,
          args.limit,
          obj.memberIds
            .map((id: number) => users.find(u => u.id === id))
            .filter(Boolean)
        );
      }
    }
  }),
  interfaces: [nodeInterface]
});

export let assigneeUnionType = new GraphQLUnionType({
  name: "AssigneeType",
  types: [userType, workingGroupType],
  resolveType(value) {
    if (value.type === "User") {
      return userType;
    } else if (value.type === "WorkingGroup") {
      return workingGroupType;
    }
  }
});

export let siteStatisticsType: GraphQLObjectType = new GraphQLObjectType({
  name: "SiteStatistics",
  fields: () => ({
    id: globalIdField(),
    weeklySales: { type: new GraphQLNonNull(GraphQLFloat) },
github Asymmetrik / graphql-fhir / src / resources / 1_0_2 / schemas / imagingstudy.schema.js View on Github external
modifierExtension: {
			type: new GraphQLList(require('./extension.schema.js')),
			description:
				'May be used to represent additional information that is not part of the basic definition of the resource, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.',
		},
		_started: {
			type: require('./element.schema.js'),
			description: 'Date and Time the study started.',
		},
		started: {
			type: DateTimeScalar,
			description: 'Date and Time the study started.',
		},
		patient: {
			type: new GraphQLNonNull(
				new GraphQLUnionType({
					name: 'ImagingStudypatient_patient_Union',
					description: 'The patient imaged in the study.',
					types: () => [require('./patient.schema.js')],
					resolveType(data) {
						if (data && data.resourceType === 'Patient') {
							return require('./patient.schema.js');
						}
					},
				}),
			),
			description: 'The patient imaged in the study.',
		},
		_uid: {
			type: require('./element.schema.js'),
			description: 'Formal identifier for the study.',
		},