0.3.11 • Published 4 years ago

nexus-graphql-api-schema-plugin v0.3.11

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

nexus-graphql-api-schema-plugin

Make's it possible to access to the nexus schema from anywhere in source definitions of Nexus.

Nexux schema is totally defined, even all queries, mutations with the args and even more.

Examples

See graphql-api-schema

Other example :

import { apiSchema } from 'graphql-api-schema'

schema.objectType({
  name: 'Country',
  definition(t) {
    t.id('id', {nullable: false})
    t.string('name', {nullable: true})
  }
})

schema.extendType({
  type: 'Query',
  definition(t) {
    if(apiSchema.stage === 'walk') {
      console.info({
        name: apiSchema.types['Country'].name,
        props: apiSchema.types['Country'].fieldList,
      }) // => { name: 'Country', props: [ 'id', 'nom' ] }
    }
    if(apiSchema.stage === 'build') {
      const fields = apiSchema.types['Country'].fields
      for(const field of apiSchema.types['Country'].fieldList) {
        const fieldType = fields[field].type
        if(fieldType.isNullable === false) {
          console.info(`The "${field}" is of type "${fieldType.of.name}" and is mandatory`)
          // => The "id" is of type "ID" and is mandatory
        } else {
          console.info(`The "${field}" is of type "${fieldType.of.name}" and is optional`)
          // => The "name" is of type "String" and is optional
        }
      }
    }
  }
})

Initialisation

import { graphqlApi } from 'nexus-graphql-api-schema-plugin'

schema.use(graphqlApi({
  dirName: 'api',
  fileName: 'apiSchema.json',
}))

Placing the file in a monitored part of the application updates apiSchema during recording.

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.7

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago