Comments (13)
That looks good, except for the schema.graphql
. The schema should be in schema.json
, and .graphql
files are then used to define queries and mutations that use the schema.
apollo-codegen
generates query-specific types, that only contain the fields you actually query for. So without any queries, API.swift
will indeed be empty.
You may want to take a look at the FrontPage example app.
from apollo-ios.
You can organize your .graphql
files any way you want, and they will all be processed together. But it is a best practice to keep your queries together with the components that use them.
An added benefit of that is that we also have an Xcode integration that shows you the corresponding .graphql
file for a Swift file in a companion view so you can edit them side by side. See the short screen recording at the end of this blog post for an example.
from apollo-ios.
I have written some query in my .graphql file but still my API.swift is empty ..can anyone help?
from apollo-ios.
Hmmm, do you have any queries defined yet in .graphql
files? Because Apollo iOS creates query-specific result types, it needs queries to generate code from.
If you have written some queries, where are your .graphql
files located? They'll have to be stored inside the project directory (or you would have to change the apollo-codegen
invocation in the run script build step).
from apollo-ios.
yep, that looks like the problem. Just had the question answered on slack. Thanks for the quick response! Really looking forward to the future of this library 😄
from apollo-ios.
I'm still getting an empty API.swift
. I've checked out the Slack channel by the way.
My .graphql
as well as the schema.json
file resides in a folder called data
right under my project folder.
So I modified $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift
with $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema data/schema.json --output API.swift
My schema has been used a few days ago in my React Native/Relay app, so I'm pretty sure my .graphql
is standard. Any possible solutions?
from apollo-ios.
So just to make sure, your .graphql
files contain queries?
Are there any error messages when you build your target?
If you've copied the default build script, it expects both your schema.json
and the .graphql
files in the target directory:
cd ${SRCROOT}/${TARGET_NAME}
So if you've put them in the parent project directory instead, that may be the issue. But I would have expected an error message in that case.
from apollo-ios.
Sorry, I haven't been doing iOS dev for about a year, so its a bit rusty.
So I've gotten rid of that data
directory I've mentioned above.
My target directory is called MusicApp
, and the actual directory structure is like this:
MusicApp
-> API.swift
-> AppDelegate.swift
-> schema.graphql
-> schema.json
Pods
I haven't got any errors when building and running the script as is which I got from the docs.
My schema contains stuff like:
schema {
query: RootQueryType
}
enum AlbumType {
SINGLE
EP
ALBUM
MAXI_ALBUM
PROMO
}
type ArticleConnection {
pageInfo: PageInfo!
edges: [ArticleEdge]
count: Int
}
etc.
from apollo-ios.
Ah, OK, that example app helped me out a lot. Thank you 🖖. I didn't quite understand what it meant by *.graphql
since my GraphQL outputs a schema.json
and schema.graphql
by default whenever I push a release.
So if there is a SoundtrackViewController.swift
there should be a SoundtrackViewController.graphql
in the target project directory, correct?
from apollo-ios.
I solved my problem. Actually my .graphql file was outside of project directory hence API.swift file was empty.
from apollo-ios.
I didn't get the solution ....Anyone please help me
from apollo-ios.
hi guys, new to apollo-ios, i still cant generate code in my API.swift, my .graphql file and schema.json are already under my project folder, any other suggestions as to this issue?
from apollo-ios.
In some cases if the syntax of queries/mutations is incorrect, you don't get any error on compile time but an empty API.swift file. Make sure that your syntax is correct.
from apollo-ios.
Related Issues (20)
- Add support for incremental cache reads
- Avoid File Overwriting for Unchanged Files HOT 1
- `InMemoryNormalizedCache` is a memory bomb HOT 5
- iOS 13.0 or newer error - compile fails HOT 3
- Custom Scalar | ApolloAPI.JSONDecodingError.couldNotConvert(value: AnyHashable to: Swift.String HOT 5
- How should I continue after handleErrorAsync inside a custom ApolloErrorInterceptor? HOT 5
- Defining a CustomScalarType which is [String:Any] HOT 12
- Deprecate `legacyResponse` and prepare for partial/incremental caching HOT 2
- Custom scalar isn't being respected HOT 7
- @defer issue HOT 8
- Documentation for @import directive. HOT 9
- Add debugDescription api for Apollo generated types
- Circular reference Build Error HOT 6
- Invalid redeclaration of synthesized property '_id' HOT 7
- Split/Hybrid Caching between InMemory and SQL review and thoughts HOT 2
- ID as a custom scalar HOT 6
- Bug: Cache writes of incremental responses uses incorrect parent key (custom cache keys)
- Incorrect PR link in release notes for version 1.11.0 HOT 2
- apollo-ios-cli deprecated --schema-name HOT 2
- Confused about cache behavior HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-ios.