Ethereum address scalar types for GraphQL
Install with yarn:
yarn add graphql-ethereum-address
Install with npm:
npm install graphql-ethereum-address
You need to add a scalar definition to your SDL type definitions and resolvers like below:
scalar EthereumAddress
You can also import ready-to-use type definitions like below:
import { EthereumAddressTypeDefinition } from 'graphql-ethereum-address';
const typeDefs = [
EthereumAddressTypeDefinition,
// other typeDefs
];
import { EthereumAddressResolver } from 'graphql-ethereum-address';
const myResolverMap = {
EthereumAddress: EthereumAddressResolver,
Query: {
// more stuff here
},
Mutation: {
// more stuff here
},
};
That's it. Now you can use the scalar type in your schema definition like this:
type Wallet {
id: String
address: EthereumAddress
}
import { asNexusMethod } from 'nexus';
import { makeSchema } from 'nexus';
import { EthereumAddressResolver } from 'graphql-ethereum-address';
const EthereumAddressScalar = asNexusMethod(EthereumAddressResolver, 'eth');
export const Wallet = objectType({
name: 'Wallet',
definition(t) {
t.string('id');
t.eth('address');
},
});
const schema = makeSchema({ types: [EthereumAddressScalar, Wallet] });
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Build the module using
yarn build
ornpm run build
- Start development server using
yarn dev
ornpm run dev