Skip to content

Commit

Permalink
use npm graphql (16) instead of deno (15)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1rtl committed Jan 28, 2023
1 parent ce66467 commit 6ffc513
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Create a GraphQL schema AST from template literal.
## Example

```ts
import { buildASTSchema, graphql } from 'https://deno.land/x/[email protected]/mod.ts'
import { buildASTSchema, graphql } from 'https://esm.sh/[email protected]'
import { gql } from 'https://deno.land/x/graphql_tag/mod.ts'

const typeDefs = gql`
Expand All @@ -32,7 +32,7 @@ console.log(await graphql(schema, query, resolvers))
[docs-badge]: https://img.shields.io/github/v/release/deno-libs/graphql-tag?color=yellow&label=Documentation&logo=deno&style=flat-square
[docs]: https://doc.deno.land/https/deno.land/x/graphql_tag/mod.ts
[releases-page]: https://github.com/deno-libs/graphql-tag/releases
[gh-actions-img]: https://img.shields.io/github/workflow/status/deno-libs/graphql-tag/CI?style=flat-square
[codecov]: https://codecov.io/gh/deno-libs/graphql-tag
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/deno-libs/graphql-tag/main.yml?branch=master&style=flat-square
[codecov]: https://codecov.io/gh/deno-libs/graphql_tag
[github-actions]: https://github.com/deno-libs/graphql-tag/actions
[codecov-badge]: https://img.shields.io/codecov/c/gh/deno-libs/graphql-tag?style=flat-square
[codecov-badge]: https://img.shields.io/codecov/c/gh/deno-libs/graphql_tag?style=flat-square
2 changes: 2 additions & 0 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { parse } from 'https://esm.sh/[email protected]/language/parser'
export type { Location, DefinitionNode, DocumentNode } from 'https://esm.sh/[email protected]/language/ast'
4 changes: 2 additions & 2 deletions example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildASTSchema, graphql } from 'https://deno.land/x/[email protected]/mod.ts'
import { buildASTSchema, graphql } from 'https://esm.sh/[email protected]'
import { gql } from './mod.ts'

const typeDefs = gql`
Expand All @@ -19,4 +19,4 @@ const resolvers = {

const schema = buildASTSchema(typeDefs)

console.log(await graphql(schema, query, resolvers))
console.log(await graphql({ schema, source: query, rootValue: resolvers }))
11 changes: 5 additions & 6 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { parse, DocumentNode, DefinitionNode, Location } from 'https://deno.land/x/[email protected]/mod.ts'

import { parse, Location, DefinitionNode, DocumentNode } from './deps.ts'
// A map docString -> graphql document
const docCache = new Map<string, DocumentNode>()

// A map fragmentName -> [normalized source]
const fragmentSourceMap = new Map<string, Set<string>>()

let printFragmentWarnings = true
let experimentalFragmentVariables = false
let allowLegacyFragmentVariables = false

// Strip insignificant whitespace
// Note that this could do a lot more, such as reorder fields etc.
Expand Down Expand Up @@ -92,7 +91,7 @@ function parseDocument(source: string) {
var cacheKey = normalize(source)
if (!docCache.has(cacheKey)) {
const parsed = parse(source, {
experimentalFragmentVariables
allowLegacyFragmentVariables
})
if (!parsed || parsed.kind !== 'Document') {
throw new Error('Not a valid GraphQL document.')
Expand Down Expand Up @@ -159,9 +158,9 @@ export function disableFragmentWarnings() {
}

export function enableExperimentalFragmentVariables() {
experimentalFragmentVariables = true
allowLegacyFragmentVariables = true
}

export function disableExperimentalFragmentVariables() {
experimentalFragmentVariables = false
allowLegacyFragmentVariables = false
}
2 changes: 1 addition & 1 deletion mod_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildASTSchema, isSchema } from 'https://deno.land/x/[email protected]/mod.ts'
import { buildASTSchema, isSchema } from 'https://esm.sh/[email protected]'
import { it, expect, run } from 'https://deno.land/x/[email protected]/mod.ts'
import { gql } from './mod.ts'

Expand Down

0 comments on commit 6ffc513

Please sign in to comment.