firestore-graphql-scalars
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

npm version

A custom GraphQL scalar type for Firebase and Google Cloud Firestore.

Installation

npm install --save firestore-graphql-scalars

or

yarn add firestore-graphql-scalars

Usage

To use this scalar you'll need to add it in two places, your schema and your resolvers map.

In your schema:

scalar Timestamp

In your resolver map, first import them:

import { timestampResolver } from 'firestore-graphql-scalars';

Then make sure they're in the root resolver map like this:

const myResolverMap = {
  Timestamp: timestampResolver,

  Query: {
    // more stuff here
  },

  Mutation: {
    // more stuff here
  },
};

Alternatively, use the default import and ES6's spread operator syntax:

import { resolvers } from 'firestore-graphql-scalars';

Then make sure they're in the root resolver map like this:

const myResolverMap = {
  ...resolvers,

  Query: {
    // more stuff here
  },

  Mutation: {
    // more stuff here
  },
};

That's it. Now you can use these scalar types in your schema definition like this:

type Person {
  createdAt: Timestamp
  ...
}

These scalars can be used just like the base, built-in ones.

Usage with Apollo Server

import { ApolloServer } from 'apollo-server';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { typeDefs, resolvers } from 'firestore-graphql-scalars';

const server = new ApolloServer({
  schema: makeExecutableSchema({
    typeDefs: [
      // use spread syntax to add scalar definitions to your schema
      ...typeDefs,
      // DateTimeTypeDefinition,
      // ...
      // ... other type definitions ...
    ],
    resolvers: {
      // use spread syntax to add scalar resolvers to your resolver map
      ...resolvers,
      // DateTimeResolver,
      // ...
      // ... remainder of resolver map ...
    },
  }),
});

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

License

Released under the MIT license.

Contributing

Issues and Pull Requests are always welcome. ❤️

Thanks

This repository is a fork of graphql-scalars. It's inspired by @lookfirst's issue and juicylevel/coffee-service. Big thanks to the contributors of these repositories! 🙏

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.227latest
2.0.1-81f789d.01alpha

Version History

VersionDownloads (Last 7 Days)Published
3.0.227
3.0.10
3.0.00
2.0.1-81f789d.01
2.0.1-d6a85bb.00
2.0.1-eb3ae73.00
2.0.1-2394813.00
2.0.1-84f5505.00
2.0.1-c23b5e0.00
2.0.1-878d7ee.00
2.0.1-732a646.00
2.0.1-e7b11bf.00
2.0.1-5a1a5dd.00
2.0.1-6f38854.00
2.0.1-67b699a.00
2.0.1-e1cc169.00
2.0.1-6fc403c.01
2.0.1-02f8771.00
2.0.1-153ab32.00
2.0.1-228680c.00
2.0.1-d22a883.00
2.0.1-ecb74ff.00
2.0.1-4c64fe3.00
2.0.1-0a1dce7.00
2.0.1-cf0a4c3.00
2.0.1-292efb1.00
2.0.1-f16e98a.00
2.0.1-c7a0a74.00
2.0.1-6a66cae.00
2.0.1-7309634.00
2.0.1-ebe529e.00
2.0.1-b6eb6bc.00
2.0.1-0bf36d8.00
2.0.1-7a85fe4.00
2.0.1-91833ae.00
2.0.1-0716db1.00
2.0.1-dae6c1a.00
2.0.1-cd2134f.01
2.0.1-5bd8218.00
2.0.1-e7bcee5.00
2.0.1-f7dc143.01
2.0.1-acf0f50.00
2.0.1-1496dce.00
2.0.1-a4cf28b.00
2.0.1-6e922ff.00
2.0.1-3a56000.00
2.0.1-caf8826.00
2.0.1-fdad4ee.00
2.0.1-3416975.00
2.0.1-b9b5b37.00
2.0.1-734d86d.00
2.0.1-d209ab4.00
2.0.1-56fd1a2.00
2.0.1-365dea1.00
2.0.1-50b51ee.00
2.0.1-a8de560.00
2.0.1-a7af0a0.00
2.0.1-480fff9.00
2.0.1-7422bba.00
2.0.1-73b1433.00
2.0.1-c36d423.00
2.0.1-82245ef.00
2.0.1-8a49dab.00
2.0.1-ebec9b4.00
2.0.1-c91a14d.00
2.0.1-c596983.00
2.0.1-cac6dd1.00
2.0.1-7b7a33a.00
2.0.1-6bc1966.00
2.0.1-40a4785.00
2.0.1-adadbba.00
2.0.1-99fa14d.00
2.0.1-b69a98d.00
2.0.1-d7bd4e5.00
2.0.1-7d1ee99.00
2.0.1-c969b8b.00
2.0.1-92ffc2b.00
2.0.1-060567f.00
2.0.1-e8c8b32.00
2.0.1-2418dd7.00
2.0.1-5bc2948.00
2.0.1-ae3ff9f.00
2.0.1-4dfcd41.00
2.0.1-ee5db92.00
2.0.1-88fd5a9.00
2.0.1-3233a02.00
2.0.1-319814f.00
2.0.1-9378293.00
2.0.1-037d495.00
2.0.1-c990f48.00
2.0.1-5a0b5cb.00
2.0.1-db7ec2c.00
2.0.1-e3be02e.00
2.0.1-423eaa7.00
2.0.1-5ab4e35.00
2.0.1-60bd90c.00
2.0.1-6167e7c.00
2.0.1-aa64577.00
2.0.1-07e38ce.00
2.0.1-11f99ac.00
2.0.1-40d50d9.00
2.0.1-de21fcc.00
2.0.1-190af1f.00
2.0.1-95b9fea.00
2.0.1-4e4a272.00
2.0.1-c052ec1.00
2.0.1-121dba6.00
2.0.1-1d19d94.00
2.0.1-2953039.00
2.0.1-b563133.00
2.0.1-9452a40.00
2.0.1-4a36aa5.00
2.0.1-deaae46.00
2.0.1-78e2b41.00
2.0.1-1a93fa5.00
2.0.1-5e74900.00
2.0.1-d6033e6.00
2.0.1-578590b.00
2.0.1-33a7598.00
2.0.1-8157c6a.00
2.0.1-6544ee6.00
2.0.1-17c7fc0.00
2.0.1-53e7035.00
2.0.1-b9a3e52.00
2.0.1-7f328fe.00
2.0.1-61af724.00
2.0.1-0af4138.00
2.0.1-2064a69.00
2.0.1-53403e8.00
2.0.1-75e3b15.00
2.0.1-e8ec815.00
2.0.1-f3a024a.00
2.0.1-99ed1fb.00
2.0.1-4d7fe2d.00
2.0.1-954a85c.00
2.0.1-72bae07.00
2.0.1-c49d3db.00
2.0.1-e6042f2.00
2.0.1-1caa37b.00
2.0.1-163aef9.00
2.0.1-8cb6605.00
2.0.1-cd0d354.00
2.0.1-f5d7a7e.00
2.0.1-6e40a59.00
2.0.1-6cb13ee.00
2.0.1-1e89640.00
2.0.1-7362d1d.00
2.0.1-a072c8d.00
2.0.1-7480bf5.00
2.0.1-8917226.00
2.0.1-514a27b.00
2.0.1-167c1dd.00
2.0.1-9370f39.00
2.0.1-6711378.00
2.0.1-63933ad.00
2.0.1-d1963c8.00
2.0.1-afd8b57.00
2.0.1-da95ef0.00
2.0.1-c50769f.00
2.0.1-2f3b959.00
2.0.1-7c291f6.00
2.0.1-03c50dc.00
2.0.1-23813ab.00
2.0.1-ee505ac.00
2.0.1-922c7e2.00
2.0.1-5a063ea.00
2.0.1-f35bb57.00
2.0.1-056670e.00
2.0.1-8185975.00
2.0.1-c257f3f.00
2.0.1-1967eb6.00
2.0.1-dcb8829.00
2.0.1-264c7c2.00
2.0.1-fcd9461.00
2.0.1-5e7ba6d.00
2.0.1-ec61552.00
2.0.1-d26adaa.00
2.0.1-b1b89d5.00
2.0.1-f2272b1.00
2.0.1-ef9ec73.00
2.0.1-799f36a.00
2.0.1-61fb6a0.00
2.0.1-35e5d75.00
2.0.1-7ef26d4.00
2.0.1-93496ad.00
2.0.1-c8e7ca5.00
2.0.1-f3f2cf8.00
2.0.1-fe1829b.00
2.0.1-d751bf7.00
2.0.1-ad035b5.00
2.0.1-f7b2ec7.00
2.0.1-5067993.00
2.0.1-6960b61.00
2.0.1-a5e2a5e.00
2.0.1-361c812.00
2.0.1-5326d15.00
2.0.1-5e41caf.00
2.0.1-fa2d58c.00
2.0.1-f88d59f.00
2.0.1-d210d36.00
2.0.1-720e924.00
2.0.1-d783882.00
2.0.1-d5e53f1.00
2.0.1-72334c2.00
2.0.1-2806f11.00
2.0.1-09bde80.00
2.0.1-74085fd.00
2.0.1-65ad318.00
2.0.1-9580c9a.00
2.0.1-3a94621.00
2.0.1-cce3898.00
2.0.1-2066305.00
2.0.1-2634b94.00
2.0.1-b084786.00
2.0.1-1ebafe4.00
2.0.1-5420342.00
2.0.1-099fbf5.00
2.0.1-b2ef6b8.00
2.0.1-40e47d6.00
2.0.1-11060a4.00
2.0.1-1bf17a1.00
2.0.1-59375c7.00
2.0.1-a464e48.00
2.0.1-381c7b5.00
2.0.1-9e2b330.00
2.0.1-04d87c5.00
2.0.1-dcf8217.00
2.0.1-9cc8793.00
2.0.1-f91429c.00
2.0.1-ee5be64.00
2.0.1-92cb016.00
2.0.1-a723940.00
2.0.1-1769e5d.00
2.0.1-de2f705.00
2.0.1-bb6e77c.00
2.0.1-052c98d.00
2.0.1-632dbb6.00
2.0.1-dea996f.00
2.0.1-f6ea0e7.00
2.0.1-2c29002.00
2.0.1-9660834.00
2.0.1-a80bf2c.00
2.0.1-acb5995.00
2.0.1-de44410.00
2.0.1-3243925.00
2.0.1-5ecdd6d.00
2.0.1-35977fb.00
2.0.1-6632044.00
2.0.1-0d3ea90.00
2.0.1-b8ffe46.00
2.0.1-daefb6d.00
2.0.1-a4220db.00
2.0.1-2ca36db.00
2.0.1-8988310.00
2.0.1-7646c49.00
2.0.1-198ba43.00
2.0.1-ba7dca5.00
2.0.1-1c72ee7.00
2.0.1-7f93259.00
2.0.1-04d5247.00
2.0.1-e7fefed.00
2.0.1-602c4a0.00
2.0.1-996fec2.00
2.0.1-933404.00
2.0.1-a2b1a9f.00
2.0.1-eb4af47.00
2.0.1-24506e6.00
2.0.1-e85895c.00
2.0.1-72f24ba.00
2.0.1-c119b5e.00
2.0.1-3d9776b.00
2.0.1-bae0b3a.00
2.0.1-d9d17ab.00
2.0.1-5f6ec3e.00
2.0.1-51bb4d7.00
2.0.1-f3dd166.00
2.0.1-1f6a5b6.00
2.0.1-cf6414e.00
2.0.1-a4c9edd.00
2.0.1-f2432c2.00
2.0.1-a4d2729.00
2.0.1-0a8ba65.00
2.0.1-78e1394.00
2.0.1-4598cc8.00
2.0.1-0ca7d97.00
2.0.1-dee6949.00
2.0.1-22bb097.00
2.0.1-7a92a54.00
2.0.1-6eac833.00
2.0.1-8f49965.00
2.0.1-51dfdf2.00
2.0.1-6d186c6.00
2.0.1-2e73500.00
2.0.1-113647b.00
2.0.1-0b88cec.00
2.0.1-754b1fe.00
2.0.1-f14e4bc.00
2.0.1-b17bf23.00
2.0.1-0dd1b3d.00
2.0.1-d8b7df3.00
2.0.1-86e7198.00
2.0.1-0092eb7.00
2.0.1-421f3d8.00
2.0.1-2636e1e.00
2.0.1-7aad2f1.00
2.0.1-7daf272.00
2.0.1-33efb72.00
2.0.1-10c195a.00
2.0.1-6ce31ce.00
2.0.1-838bc7a.00
2.0.1-e41bed1.00
2.0.1-fcd1918.00
2.0.1-49606f4.00
2.0.1-cc825ee.00
2.0.1-e0dfeda.00
2.0.1-3e8602f.00
2.0.1-748807c.00
2.0.1-f0ae96c.00
2.0.1-55c4143.00
2.0.1-fdcd798.00
2.0.1-a302c80.00
2.0.1-2839e70.00
2.0.1-0fac458.01
2.0.1-51779f5.00
2.0.1-855f072.00
2.0.1-577b426.00
2.0.1-da6f83d.00
2.0.1-0b9c28b.00
2.0.1-66dab8f.00
2.0.1-19cb373.00
2.0.1-56172e3.00
2.0.1-0bba6ab.00
2.0.1-8512c09.01
2.0.1-642807a.00
2.0.1-3376404.00
2.0.1-0e6baf9.00
2.0.1-86b1399.00
2.0.1-260b332.00
2.0.1-e7c2303.00
2.0.1-0fbefef.00
2.0.1-406a60c.00
2.0.1-80e0fe9.00
2.0.1-e228beb.01
2.0.1-c36d8d1.00
2.0.1-00e3013.00
2.0.1-a0041df.00
2.0.1-566c7b6.00
1.0.1-cb1e6d2.01
1.0.1-476dd45.00
1.0.1-e0b0cbd.01
1.0.1-f68ff8e.01
1.0.1-5120d4d.00
1.0.1-ca21737.00
1.0.1-6aac80a.00
1.0.1-618ba62.00
1.0.1-c455a40.00
1.0.1-a6b6f92.00
1.0.1-554b557.00
1.0.1-859eaee.00
1.0.1-394c7e9.00
1.0.1-fa049c4.00
1.0.1-367863b.00

Package Sidebar

Install

npm i firestore-graphql-scalars

Weekly Downloads

37

Version

3.0.2

License

MIT

Unpacked Size

17.4 kB

Total Files

15

Last publish

Collaborators

  • simenandre