Skip to content

Instantly share code, notes, and snippets.

@litewarp
Last active July 4, 2021 19:27
Show Gist options
  • Select an option

  • Save litewarp/913c1f77581f2ed7e75d7c489b79488c to your computer and use it in GitHub Desktop.

Select an option

Save litewarp/913c1f77581f2ed7e75d7c489b79488c to your computer and use it in GitHub Desktop.

Revisions

  1. litewarp revised this gist Jul 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ import { typeDefs } from './typeDefs'
    // see https://www.graphql-tools.com/docs/schema-wrapping#renaming

    const renamingFn = (typeName: string, fieldName: string): string => {
    if (inputFieldName === 'skip') {
    if (fieldName === 'skip') {
    return 'offset'
    }
    return inputFieldName
  2. litewarp revised this gist Jul 3, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    // temporary fix for https://github.com/neo4j/graphql/issues/292

    import { gql } from 'apollo-server'
    import { wrapSchema, RenameInputObjectFields } from '@graphql-tools/wrap'
    import { Neo4jGraphQL } from '@neo4j/graphql'
    import { typeDefs } from './typeDefs'
  3. litewarp revised this gist Jul 3, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // temporary fix for https://github.com/neo4j/graphql/issues/292

    import { gql } from 'apollo-server'
    import { wrapSchema, RenameInputObjectFields } from '@graphql-tools/wrap'
    import { Neo4jGraphQL } from '@neo4j/graphql'
  4. litewarp revised this gist Jul 3, 2021. 2 changed files with 20 additions and 18 deletions.
    10 changes: 0 additions & 10 deletions transformers.ts
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@

    export const schemaTransformer = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => {
    if (fieldConfig.args?.skip) {
    const { skip, ...rest } = fieldConfig.args
    return { ...fieldConfig, args: { ...rest, offset: skip }}
    }
    return fieldConfig
    }

    export const
    28 changes: 20 additions & 8 deletions wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,23 @@
    import { wrapSchema, TransformObjectFields } from '@graphql-tools/wrap'
    import { schema } from './schema'
    import { gql } from 'apollo-server'
    import { wrapSchema, RenameInputObjectFields } from '@graphql-tools/wrap'
    import { Neo4jGraphQL } from '@neo4j/graphql'
    import { typeDefs } from './typeDefs'

    const sche
    // renames all InputObjectFields matching 'skip'
    // see https://www.graphql-tools.com/docs/schema-wrapping#renaming

    const renamingFn = (typeName: string, fieldName: string): string => {
    if (inputFieldName === 'skip') {
    return 'offset'
    }
    return inputFieldName
    }

    const neoSchema = new Neo4jGraphQL({ typeDefs })

    export const schema = wrapSchema({
    schema: neoSchema.schema,
    transforms: [new RenameInputObjectFields(renamingFn)]
    })

    const objectFieldTransformer = new TransformObjectFields()

    const wrappedSchema = wrapSchema({
    schema: schema,
    transforms: []
    })
  5. litewarp revised this gist Jul 2, 2021. 2 changed files with 21 additions and 1 deletion.
    10 changes: 10 additions & 0 deletions transformers.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@

    export const schemaTransformer = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => {
    if (fieldConfig.args?.skip) {
    const { skip, ...rest } = fieldConfig.args
    return { ...fieldConfig, args: { ...rest, offset: skip }}
    }
    return fieldConfig
    }

    export const
    12 changes: 11 additions & 1 deletion wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -1 +1,11 @@
    s
    import { wrapSchema, TransformObjectFields } from '@graphql-tools/wrap'
    import { schema } from './schema'

    const sche

    const objectFieldTransformer = new TransformObjectFields()

    const wrappedSchema = wrapSchema({
    schema: schema,
    transforms: []
    })
  6. litewarp created this gist Jul 2, 2021.
    1 change: 1 addition & 0 deletions wrapper.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    s