Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sikanhe committed Dec 5, 2023
1 parent 7a793f8 commit 1a6de3d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Most importantly, we achieve all this _without_ having to:
### What does it look like?

```ts
import { buildGraphQLSchema, id, string } from 'gqtx';
import { Gql, buildGraphQLSchema } from 'gqtx';

enum Role {
Admin,
Expand All @@ -49,13 +49,13 @@ const users: User[] = [
// We can declare the app context type once, and it will
// be automatically inferred for all our resolvers
declare module "gqtx" {
interface Context {
interface GqlContext {
viewerId: number;
users: User[];
}
}

const RoleEnum = enumType({
const RoleEnum = Gql.Enum({
name: 'Role',
description: 'A user role',
values: [
Expand All @@ -64,23 +64,23 @@ const RoleEnum = enumType({
],
});

const UserType = objectType<User>({
const UserType = Gql.Object<User>({
name: 'User',
description: 'A User',
fields: () => [
field({ name: 'id', type: nonnull(id) }),
field({ name: 'role', type: nonnull(RoleEnum) }),
field({ name: 'name', type: nonnull(string) }),
Gql.Field({ name: 'id', type: Gql.NonNull(Gql.ID) }),
Gql.Field({ name: 'role', type: Gql.NonNull(RoleEnum) }),
Gql.Field({ name: 'name', type: Gql.NonNull(Gql.String) }),
],
});

const Query = queryType({
const Query = Gql.Query({
fields: [
field({
Gql.Field({
name: 'userById',
type: UserType,
args: {
id: arg({ type: nonnullInput(id) }),
id: Gql.Arg({ type: Gql.NonNullInput(Gql.ID) }),
},
resolve: (_, args, ctx) => {
// `args` is automatically inferred as { id: string }
Expand Down

1 comment on commit 1a6de3d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes have been published to npm.

yarn add -E [email protected]

Please sign in to comment.