Created
September 28, 2017 16:06
-
-
Save typesend/56846a07355ff6dd16b2d305f55c8973 to your computer and use it in GitHub Desktop.
Initial Oscar Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var graphqlHTTP = require('express-graphql'); | |
// var GraphQLJSON = require('graphql-type-json'); | |
var { buildSchema } = require('graphql'); | |
var schema = buildSchema(` | |
# Temporary placeholder type for development. | |
scalar TBD | |
# A JSON Web Token string. | |
scalar JWT | |
# A SHA256 hash value. | |
scalar Hashcode | |
# Social Security Number with hyphens. | |
scalar SSN | |
# Phone number like "(XXX) XXX-XXXX" | |
scalar PhoneNumber | |
scalar URL | |
# DL or other ID Number. | |
scalar DLID | |
# An email address. | |
scalar EmailAddress | |
# IPv4 address. | |
scalar IP | |
# UTC timestamp formatted per ISO 8601: 2017-09-28T12:17:05Z | |
scalar DateTime | |
# ISO 8601 date, e.g. 2017-12-06. See https://xkcd.com/1179/ | |
scalar Date | |
scalar Cursor | |
# Indicates DMV legacy backends are used under the hood. | |
interface DMVLegacyBackend { | |
# List of DMV backends used. | |
backends: [String!]! | |
} | |
enum VoterRegistrationSource { | |
DIGITAL | |
} | |
type VoterCountiesFields { | |
former: String | |
current: String | |
} | |
type NameFields { | |
first: String! | |
middle: String | |
last: String | |
suffix: String | |
} | |
input InputNameFields { | |
first: String! | |
middle: String | |
last: String | |
suffix: String | |
} | |
type Address { | |
street: String | |
state: String | |
city: String | |
zip: String | |
} | |
type VoterAddressFields { | |
formerResidence: Address | |
currentResidence: Address | |
formerMailing: Address | |
currentMailing: Address | |
} | |
type VoterLanguageFields { | |
electionMaterial: String | |
application: String | |
} | |
# Useful for detecting breaks in the chain of voter registration events. | |
interface ImmutableBlockchain { | |
chainId: Hashcode! | |
prevBlock: Hashcode! | |
thisBlock: Hashcode! | |
createdAt: DateTime! | |
} | |
type VoterRegistration implements ImmutableBlockchain { | |
id: ID! | |
# Base64-encoded value of id used for paging. | |
cursor: ID! | |
chainId: Hashcode! | |
prevBlock: Hashcode! | |
thisBlock: Hashcode! | |
createdAt: DateTime! | |
source: VoterRegistrationSource! | |
customerFormId: ID | |
receivedOn: Date! | |
effectiveAt: DateTime! | |
idNumber: DLID! | |
name: NameFields! | |
dateOfBirth: Date! | |
email: String | |
deleteEmail: Boolean! | |
phone: String | |
deletePhone: Boolean! | |
addresses: VoterAddressFields! | |
counties: VoterCountiesFields | |
coaOptOut: Boolean! | |
languages: VoterLanguageFields! | |
registrationOptOut: Boolean! | |
votingByMail: Boolean! | |
party: String | |
otherParty: String | |
} | |
input IdentificationLookup { | |
number: ID! | |
state: String! | |
name: InputNameFields! | |
address: String! | |
ssn: SSN! | |
dob: Date! | |
} | |
# DMV's customer record | |
type CustomerRecord implements DMVLegacyBackend { | |
id: ID! | |
# Whether a renewal must be processed in-person at a DMV field office. | |
officeVisitRequired: Boolean! | |
backends: [String!]! | |
} | |
type CustomerProblem { | |
# Instructions displayable to the customer. | |
customerInstructions: [String!]! | |
# Instructions helpful to DMV technicians. | |
technicianInstructions: [String!]! | |
# e.g. CDLIS, PDPS | |
source: String! | |
} | |
type OfficeAddress { | |
street: String | |
state: String | |
city: String | |
zip: String | |
} | |
type OfficeLocation { | |
id: ID! | |
name: String! | |
address: OfficeAddress | |
phone: PhoneNumber! | |
url: URL! | |
} | |
type AdverseAction { | |
# (Some forms ask for a complete date.) | |
date: Date! | |
# (Some forms do not ask for a complete date.) | |
year: Int! | |
reason: String! | |
} | |
type CustomerProblemsPayload { | |
unableToContinue: Boolean! | |
problemCount: Int! | |
problems: [CustomerProblem] | |
} | |
type CustomerFormAddressFields { | |
changeOfAddress: Boolean! | |
updateVoterRegistration: Boolean! | |
formerResidence: Address | |
currentResidence: Address | |
formerMailing: Address | |
currentMailing: Address | |
sameAsResidential: Boolean! | |
} | |
# Base64-encoded image data, | |
# e.g. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." | |
scalar DataURI | |
interface Signature { | |
# Base64-encoded image data | |
signatureImage: DataURI! | |
dated: DateTime! | |
} | |
type SignatureFields implements Signature { | |
signatureImage: DataURI! | |
dated: DateTime! | |
phone: PhoneNumber! | |
} | |
type ParentGuardianSignatureFields implements Signature { | |
acceptanceOfLiability: Boolean! | |
signatureImage: DataURI! | |
acceptedBy: NameFields! | |
dated: DateTime! | |
phone: PhoneNumber! | |
address: Address! | |
} | |
type VeteranStatementsFields { | |
militaryService: Boolean! | |
requestVAInfo: Boolean! | |
displayOnCard: Boolean! | |
} | |
type OrganDonationFields { | |
# Adds/keeps or removes customer from organ and tissue donor registry. | |
register: Boolean! | |
# Would you like to make a voluntary $2 donation? | |
monetaryDonation: Boolean! | |
} | |
interface DriverLicense { | |
# Driver license number. | |
idNumber: DLID! | |
# State or country of issuance. | |
issuedBy: String! | |
name: NameFields! | |
} | |
# Prior driver license issued by another state or country. Fields based on DL939. | |
type OtherDriverLicense implements DriverLicense { | |
idNumber: DLID! | |
# State or country of issuance. | |
issuedBy: String! | |
# Social security number. | |
ssn: SSN! | |
# Date the identification card expires. | |
dateOfBirth: Date! | |
name: NameFields! | |
sex: String! | |
} | |
# Has the customer had any medical conditions in the last three years that | |
# affected their ability to drive? | |
type MedicalConditionFields { | |
drivingAffected: Boolean! | |
explanation: String | |
} | |
type Identification { | |
# Driver license or ID card number. | |
number: DLID! | |
# State or country of issuance. | |
issuedBy: String! | |
# Date the identification card expires. | |
expirationDate: Date! | |
} | |
enum CustomerIntentions { | |
APPLY_FOR_DL_CLASS_C | |
APPLY_FOR_MOTORCYCLE | |
APPLY_FOR_NONCOMMERCIAL_CLASS_A # Fifth-Wheel/Travel Trailer | |
APPLY_FOR_HOUSECAR | |
APPLY_FOR_ID_CARD | |
APPLY_FOR_SENIOR_ID_CARD | |
CHANGE_OF_ADDRESS | |
ORIGINAL_DL_OR_PERMIT | |
CHANGE_OR_ADD_CLASS | |
RENEWAL | |
REMOVE_RESTRICTION | |
DUPLICATE_DL_LOST | |
DUPLICATE_DL_STOLEN | |
NAME_CHANGE_OR_CORRECTION | |
CLASS_A | |
CLASS_B | |
CLASS_C | |
DOUBLES_TRIPLES | |
FIREFIGHTER_ENDORSEMENT | |
HAZARDOUS_MATERIALS_WASTE | |
PASSENGER_TRANSPORT | |
SCHOOL_BUS | |
TANK | |
AMBULANCE_CERTIFICATE | |
VERIFICATION_OF_TRANSIT_TRAINING | |
NO_AIR_BRAKES_RESTRICTION_48 | |
MAKE_CHANGE_OR_CORRECTION | |
RENEW_EXPIRING_DL_OR_ID | |
REPLACE_LOST_STOLEN_OR_DAMAGED_CARD | |
REDUCED_FEE_ID_CARD | |
ADD_FIREFIGHTER_ENDORSEMENT | |
REMOVE_FIREFIGHTER_ENDORSEMENT | |
} | |
# Senior ID card, Name Change, Ambulance Certificate, Housecar, etc. | |
type Intention { | |
type: CustomerIntentions! | |
description: String! | |
} | |
type VoterFormQuestions { | |
# Citizenship (5a) | |
citizen: Boolean | |
# Eligibility (5b) | |
eligible: Boolean | |
# Opt-out (5c) | |
optOut: Boolean | |
# Vote by mail | |
votingByMail: Boolean! | |
# Language preference for election materials. | |
electionMaterialLanguage: String! | |
# Party preference. | |
party: String | |
# Write-in party preference. | |
otherParty: String | |
# No party affiliation. | |
noParty: Boolean | |
email: String | |
deleteEmail: Boolean! | |
phone: String | |
deletePhone: Boolean! | |
coaCounties: VoterCountiesFields | |
coaOptOut: Boolean! | |
} | |
type FederalRegulationCertificationFields { | |
nonExceptedInterstate: Boolean! | |
nonExceptedIntrastate: Boolean! | |
exceptedInterstate: Boolean! | |
exceptedIntrastate: Boolean! | |
} | |
type CustomerFormVehicle { | |
# CA Plate/CF/Placard number | |
number: String | |
# Last 17 positions of Vehicle or Vessel ID | |
vID: String | |
registeredOutsideCA: Boolean | |
leased: Boolean | |
leasingCompany: String | |
# Location of Trailer Coach or Vessel | |
location: Address | |
oldAddress: Address | |
} | |
type RenewalByMailEligibility { | |
lastTwoByMail: Boolean | |
expiredOneYearPlus: Boolean | |
expires60PlusDays: Boolean | |
drivingProbation: Boolean | |
nameChangeOrCorrection: Boolean | |
healthOrVisionProblems: Boolean | |
movingViolations: Boolean | |
failureToAppear: Boolean | |
suspendedBecausePAS: Boolean | |
atFaultCollisions: Boolean | |
multipleDriverLicenses: Boolean | |
} | |
union CustomerFormCertification = SignatureFields | ParentGuardianSignatureFields | |
type CustomerForm { | |
id: ID! | |
# What are they applying for? What is the purpose of their visit? | |
intentions: [Intention!] | |
renewalByMailEligibility: RenewalByMailEligibility | |
name: NameFields | |
dateOfBirth: Date | |
ssn: SSN | |
identification: Identification | |
addresses: CustomerFormAddressFields | |
voterRegistration: VoterFormQuestions | |
formLanguage: String! | |
sex: String | |
hairColor: String | |
eyeColor: String | |
# Height in inches. | |
height: Int | |
# Weight in pounds. | |
weight: Int | |
# Has their driver license ever been revoked, suspended, or canceled? | |
adverseActions: [AdverseAction!] | |
federalCertifications: FederalRegulationCertificationFields | |
medicalConditions: MedicalConditionFields | |
veteranStatements: VeteranStatementsFields | |
organDonation: OrganDonationFields | |
# Includes names provided in conjunction with prior license information. | |
priorNames: [String!] | |
priorLicenses: [OtherDriverLicense!] | |
certification: CustomerFormCertification | |
vehicles: [CustomerFormVehicle!] | |
createdAt: DateTime! | |
modifiedAt: DateTime! | |
yieldedAt: DateTime | |
finalizedAt: DateTime | |
} | |
type Query { | |
# Fetch information collected from the customer. | |
customerForm(id: ID): CustomerForm | |
# Reserved for use by Secretary of State | |
voterRegistrations(after: Cursor, before: Cursor, limit: Int): [VoterRegistration] | |
# Requests DMV records for a given customer. | |
customerRecord(lookup: IdentificationLookup!): CustomerRecord | |
# Identifies any problems that prevent the customer from obtaining | |
# a license or identification card. | |
customerProblems(lookup: IdentificationLookup!): CustomerProblemsPayload | |
# Information about the current user. | |
me: Token | |
# Guess field office location of user based on IP address. | |
presumeUserLocation(ip: IP!): OfficeLocation | |
# Compare the time of this host, the client, and a government time server. | |
now(myTime: DateTime): [DateTime!]! | |
officeLocation(id: ID, name: String): OfficeLocation | |
officeLocations(before: ID, after: ID, limit: Int = 200): [OfficeLocation] | |
} | |
type Token { | |
token: JWT! | |
alg: String! | |
iss: String! | |
exp: DateTime! | |
sub: String | |
aud: String | |
scopes: String | |
} | |
enum AuthService { | |
DMV_LDAP | |
DMV_AD | |
SOS_HMMM | |
} | |
input Credentials { | |
username: String! | |
password: String! | |
service: AuthService! | |
} | |
type Acknowledgement { | |
result: String! | |
} | |
type Failure { | |
result: String! | |
} | |
union DMVResponse = Acknowledgement | Failure | |
union ReplyToDMV = Acknowledgement | Failure | |
union Result = Acknowledgement | Failure | |
type Mutation { | |
# Login | |
createToken(credentials: Credentials!, locationName: String!, context: String!): Token | |
# Used to stage customer data for use in EASE. | |
yield(id: ID!): DMVResponse | |
# Triggered by DMV upon receiving customer payment. | |
finalize(id: ID!): ReplyToDMV | |
# Remember that we need to be able to send transactional emails on behalf of DMV. | |
sendEmail(recipient: EmailAddress!, event: ID!): Result | |
} | |
`); | |
// Maps id to User object | |
var fakeDatabase = { | |
'a': { | |
id: 'a', | |
name: 'alice', | |
}, | |
'b': { | |
id: 'b', | |
name: 'bob', | |
}, | |
}; | |
var root = { | |
user: function ({id}) { | |
return fakeDatabase[id]; | |
} | |
}; | |
var app = express(); | |
app.use('/graphql', graphqlHTTP({ | |
schema: schema, | |
rootValue: root, | |
graphiql: true, | |
})); | |
app.listen(4000); | |
console.log('GraphQL API server running at localhost:4000/graphql'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment