Last active
March 3, 2018 13:53
-
-
Save akoenig/810d01c5f4f4930606a71d8e1b92e792 to your computer and use it in GitHub Desktop.
Medium: M2M in GraphQL context (Fetch User Registrations In The Last Hour)
This file contains hidden or 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
import { request } from "graphql-request"; | |
export const fetchUserRegistrationsInLastHour = async (period: string) => { | |
const query = ` | |
query UserRegistrationsWithinPeriod($period: String!) { | |
users(where: { | |
createdAt: $period | |
} { | |
id | |
} | |
} | |
`; | |
const { UserRegistrationsWithinPeriod } = await request('<graphql-endpoint>', query, {period}); | |
return UserRegistrationsWithinPeriod.length; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment