Skip to content

Statically compiled resolvers for entire queries based on a graphql-js schema.

License

Notifications You must be signed in to change notification settings

alloy/graphqless-js

Repository files navigation

graphqless

Statically compiled resolvers for entire queries based on a graphql-js schema. That is, for a operation document and an executable schema, the graphqless compiler will output JavaScript code that is able to execute that operation without any GraphQL runtime execution overhead such as parsing, validating, and figuring out what resolvers to invoke.

⚠️ This is currenntly a proof-of-concept implementation to research feasability and uncover considerations to take into account. Any such considerations will be disucced in the issue tracker.

Example

Turns this:

query SomeQuery {
  anObjectRootField {
    aNestedScalarField
  }
}

…into this:

;(function SomeQuery(schema, rootValue) {
  return {
    data: {
      anObjectRootField: (function () {
        const result_1 = schema
          .getType("Query")
          .toConfig()
          .fields.anObjectRootField.resolve(rootValue, {}, undefined)

        if (result_1) {
          return Object.assign({}, result_1, {
            aNestedScalarField: schema
              .getType("AnObjectRootFieldType")
              .toConfig()
              .fields.aNestedScalarField.resolve(result_1, {}, undefined, {}),
          })
        }
      })(),
    },
  }
})

About

Statically compiled resolvers for entire queries based on a graphql-js schema.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published