Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(getTypeByName): register default types like JSON earlier #135

Merged
merged 1 commit into from
Dec 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 41 additions & 40 deletions packages/graphile-build-pg/src/plugins/PgTypesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,46 +311,47 @@ export default (function PgTypesPlugin(
"UUID",
"A universally unique identifier as defined by [RFC 4122](https://tools.ietf.org/html/rfc4122)."
);
const oidLookup = Object.assign(
{
"20": stringType(
"BigInt",
"A signed eight-byte integer. The upper big integer values are greater then the max value for a JavaScript number. Therefore all big integers will be output as strings and not numbers."
), // bitint - even though this is int8, it's too big for JS int, so cast to string.
"21": GraphQLInt, // int2
"23": GraphQLInt, // int4
"700": GraphQLFloat, // float4
"701": GraphQLFloat, // float8
"1700": GraphQLString, // numeric
"790": GraphQLFloat, // money

"1186": GQLInterval, // interval
"1082": SimpleDate, // date
"1114": SimpleDatetime, // timestamp
"1184": SimpleDatetime, // timestamptz
"1083": SimpleTime, // time
"1266": SimpleTime, // timetz

"114": SimpleJSON, // json
"3802": SimpleJSON, // jsonb
"2950": SimpleUUID, // uuid

"1560": GraphQLString, // bit
"1562": GraphQLString, // varbit
},
pgExtendedTypes && {
"114": GraphQLJSON,
"3802": GraphQLJSON,
/*
'1082': GraphQLDate, // date
'1114': GraphQLDateTime, // timestamp
'1184': GraphQLDateTime, // timestamptz
'1083': GraphQLTime, // time
'1266': GraphQLTime, // timetz
'2950': GraphQLUUID,
*/
}
);

// pgExtendedTypes might change what types we use for things
const JSONType = pgExtendedTypes ? GraphQLJSON : SimpleJSON;
const UUIDType = SimpleUUID; // GraphQLUUID
const DateType = SimpleDate; // GraphQLDate
const DateTimeType = SimpleDatetime; // GraphQLDateTime
const TimeType = SimpleTime; // GraphQLTime

// Other plugins might want to use JSON
addType(JSONType);
addType(UUIDType);
addType(DateType);
addType(DateTimeType);
addType(TimeType);

const oidLookup = {
"20": stringType(
"BigInt",
"A signed eight-byte integer. The upper big integer values are greater then the max value for a JavaScript number. Therefore all big integers will be output as strings and not numbers."
), // bitint - even though this is int8, it's too big for JS int, so cast to string.
"21": GraphQLInt, // int2
"23": GraphQLInt, // int4
"700": GraphQLFloat, // float4
"701": GraphQLFloat, // float8
"1700": GraphQLString, // numeric
"790": GraphQLFloat, // money

"1186": GQLInterval, // interval
"1082": DateType, // date
"1114": DateTimeType, // timestamp
"1184": DateTimeType, // timestamptz
"1083": TimeType, // time
"1266": TimeType, // timetz

"114": JSONType, // json
"3802": JSONType, // jsonb
"2950": UUIDType, // uuid

"1560": GraphQLString, // bit
"1562": GraphQLString, // varbit
};
const oidInputLookup = {
"1186": GQLIntervalInput, // interval
};
Expand Down