Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
graphql-date-scalars
Advanced tools
GraphQL Scalars for Date (YYYY-MM-DD), DateTime (YYYY-MM-DDTHH:MM:SSZ), and Time (HH:MM:SSZ)
import { gql, ApolloServer } from 'apollo-server';
import { DateScalar, TimeScalar, DateTimeScalar } from 'graphql-date-scalars';
const resolvers = {
// Must define resolvers for these scalars
Date: DateScalar,
Time: TimeScalar,
DateTime: DateTimeScalar,
// along with all your other resolvers
Query: {
exampleDateQuery: () => {
// Will serialize to a date string, such as 2007-12-03
return new Date();
},
exampleTimeQuery: () => {
// Will serialize to a time string at UTC, such as 10:15:30Z
return new Date();
},
},
Mutation: {
exampleDateTimeMutation: () => {
// Will serialize to a date-time string at UTC, such as 2007-12-03T10:15:30Z
return new Date();
},
},
};
const typeDefs = gql`
scalar Date
scalar DateTime
extend type Query {
exampleDateQuery: Date!
exampleTimeQuery: Time!
}
extend type Mutation {
exampleDateTimeMutation: DateTime!
}
`;
const server = new ApolloServer({
typeDefs,
resolvers,
});
If you are using @graphql-codegen
then you must include these scalars in your codegen yml file under config
schema: './example-schema.graphql'
config:
scalars:
Date: Date
Time: Date
DateTime: Date
generates:
src/types/example-schema.d.ts:
plugins:
- 'typescript'
You can also use the parse and serialize methods directly, which is useful if you are making a rest call to a 3rd party vendor.
import { DateTimeScalar } from 'graphql-date-scalars';
const vendorResponse = await restClient.get();
const response = {
...vendorResponse,
createdAt: DateTimeScalar.parseValue(vendorResponse.createdAt),
};
import { DateScalar } from 'graphql-date-scalars';
const args = {
...input,
dateOfBirth: DateScalar.serialize(input.dateOfBirth),
};
const response = await restClient.post(args);
npm i
npm run build
To clean the build directory run npm run clean
npm run test
package.json
CHANGELOG.md
entrynpm pack
to see what will be published then delete the .tgz
file that was creatednpm publish
1.0.0
the tag and release name would be v1.0.0
.This project started as a fork of https://github.com/excitement-engineer/graphql-iso-date
FAQs
GraphQL scalars for Date, DateTime and Time
The npm package graphql-date-scalars receives a total of 5,492 weekly downloads. As such, graphql-date-scalars popularity was classified as popular.
We found that graphql-date-scalars demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 164 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.