View Source GraphQLDocument
Build GraphQL document strings from Elixir primitives.
better-dx-for-internal-graphql-queries
Better DX for internal GraphQL queries
The goal of GraphQLDocument is to improve the developer experience of making GraphQL calls in Elixir by calling directly into GraphQL libraries such as Absinthe without making API calls.
For Elixir projects that utilize LiveView
and GraphQL, passing GraphQL queries as strings, GraphQLDocument
can add value by
making it easier to:
- Compose separate GraphQL documents together.
- Dynamically build GraphQL documents, e.g. including or excluding various parts.
- Interpolate arguments safely.
installation
Installation
Add :graphql_document
as a dependency in mix.exs
:
def deps do
[
{:graphql_document, "~> 0.1.0"}
]
end
usage
Usage
with-absinthe
With Absinthe
[
query: [
user: {
[id: 3],
[:name, :age, :height, documents: [:filename, :url]]
}
]
]
|> GraphQLDocument.to_string()
|> Absinthe.run(MyProject.Schema)
For more information on syntax and features, read the docs in GraphQLDocument
.
license
License
Copyright 2022 United Community Bank
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.